
obj/fs/fs:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 e3 1d 00 00       	call   801e14 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <ide_wait_ready>:

static int diskno = 1;

static int
ide_wait_ready(bool check_error)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	53                   	push   %ebx
  800044:	89 c1                	mov    %eax,%ecx

static __inline uint8_t
inb(int port)
{
	uint8_t data;
	__asm __volatile("inb %w1,%0" : "=a" (data) : "d" (port));
  800046:	ba f7 01 00 00       	mov    $0x1f7,%edx
  80004b:	ec                   	in     (%dx),%al
	int r;

	while (((r = inb(0x1F7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY)
  80004c:	0f b6 d8             	movzbl %al,%ebx
  80004f:	89 d8                	mov    %ebx,%eax
  800051:	25 c0 00 00 00       	and    $0xc0,%eax
  800056:	83 f8 40             	cmp    $0x40,%eax
  800059:	75 f0                	jne    80004b <ide_wait_ready+0xb>
		/* do nothing */;

	if (check_error && (r & (IDE_DF|IDE_ERR)) != 0)
  80005b:	85 c9                	test   %ecx,%ecx
  80005d:	74 0a                	je     800069 <ide_wait_ready+0x29>
  80005f:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  800064:	f6 c3 21             	test   $0x21,%bl
  800067:	75 05                	jne    80006e <ide_wait_ready+0x2e>
  800069:	b8 00 00 00 00       	mov    $0x0,%eax
		return -1;
	return 0;
}
  80006e:	5b                   	pop    %ebx
  80006f:	5d                   	pop    %ebp
  800070:	c3                   	ret    

00800071 <ide_write>:
	return 0;
}

int
ide_write(uint32_t secno, const void *src, size_t nsecs)
{
  800071:	55                   	push   %ebp
  800072:	89 e5                	mov    %esp,%ebp
  800074:	57                   	push   %edi
  800075:	56                   	push   %esi
  800076:	53                   	push   %ebx
  800077:	83 ec 1c             	sub    $0x1c,%esp
  80007a:	8b 75 08             	mov    0x8(%ebp),%esi
  80007d:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800080:	8b 7d 10             	mov    0x10(%ebp),%edi
	int r;
	
	assert(nsecs <= 256);
  800083:	81 ff 00 01 00 00    	cmp    $0x100,%edi
  800089:	76 24                	jbe    8000af <ide_write+0x3e>
  80008b:	c7 44 24 0c 60 46 80 	movl   $0x804660,0xc(%esp)
  800092:	00 
  800093:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  80009a:	00 
  80009b:	c7 44 24 04 5c 00 00 	movl   $0x5c,0x4(%esp)
  8000a2:	00 
  8000a3:	c7 04 24 82 46 80 00 	movl   $0x804682,(%esp)
  8000aa:	e8 d1 1d 00 00       	call   801e80 <_panic>

	ide_wait_ready(0);
  8000af:	b8 00 00 00 00       	mov    $0x0,%eax
  8000b4:	e8 87 ff ff ff       	call   800040 <ide_wait_ready>
}

static __inline void
outb(int port, uint8_t data)
{
	__asm __volatile("outb %0,%w1" : : "a" (data), "d" (port));
  8000b9:	ba f2 01 00 00       	mov    $0x1f2,%edx
  8000be:	89 f8                	mov    %edi,%eax
  8000c0:	ee                   	out    %al,(%dx)
  8000c1:	b2 f3                	mov    $0xf3,%dl
  8000c3:	89 f0                	mov    %esi,%eax
  8000c5:	ee                   	out    %al,(%dx)
  8000c6:	89 f0                	mov    %esi,%eax
  8000c8:	c1 e8 08             	shr    $0x8,%eax
  8000cb:	b2 f4                	mov    $0xf4,%dl
  8000cd:	ee                   	out    %al,(%dx)
  8000ce:	89 f0                	mov    %esi,%eax
  8000d0:	c1 e8 10             	shr    $0x10,%eax
  8000d3:	b2 f5                	mov    $0xf5,%dl
  8000d5:	ee                   	out    %al,(%dx)
  8000d6:	a1 00 90 80 00       	mov    0x809000,%eax
  8000db:	83 e0 01             	and    $0x1,%eax
  8000de:	c1 e0 04             	shl    $0x4,%eax
  8000e1:	83 c8 e0             	or     $0xffffffe0,%eax
  8000e4:	c1 ee 18             	shr    $0x18,%esi
  8000e7:	83 e6 0f             	and    $0xf,%esi
  8000ea:	09 f0                	or     %esi,%eax
  8000ec:	b2 f6                	mov    $0xf6,%dl
  8000ee:	ee                   	out    %al,(%dx)
  8000ef:	b2 f7                	mov    $0xf7,%dl
  8000f1:	b8 30 00 00 00       	mov    $0x30,%eax
  8000f6:	ee                   	out    %al,(%dx)
	outb(0x1F4, (secno >> 8) & 0xFF);
	outb(0x1F5, (secno >> 16) & 0xFF);
	outb(0x1F6, 0xE0 | ((diskno&1)<<4) | ((secno>>24)&0x0F));
	outb(0x1F7, 0x30);	// CMD 0x30 means write sector

	for (; nsecs > 0; nsecs--, src += SECTSIZE) {
  8000f7:	85 ff                	test   %edi,%edi
  8000f9:	74 2a                	je     800125 <ide_write+0xb4>
		if ((r = ide_wait_ready(1)) < 0)
  8000fb:	b8 01 00 00 00       	mov    $0x1,%eax
  800100:	e8 3b ff ff ff       	call   800040 <ide_wait_ready>
  800105:	85 c0                	test   %eax,%eax
  800107:	78 21                	js     80012a <ide_write+0xb9>
}

static __inline void
outsl(int port, const void *addr, int cnt)
{
	__asm __volatile("cld\n\trepne\n\toutsl"		:
  800109:	89 de                	mov    %ebx,%esi
  80010b:	b9 80 00 00 00       	mov    $0x80,%ecx
  800110:	ba f0 01 00 00       	mov    $0x1f0,%edx
  800115:	fc                   	cld    
  800116:	f2 6f                	repnz outsl %ds:(%esi),(%dx)
	outb(0x1F4, (secno >> 8) & 0xFF);
	outb(0x1F5, (secno >> 16) & 0xFF);
	outb(0x1F6, 0xE0 | ((diskno&1)<<4) | ((secno>>24)&0x0F));
	outb(0x1F7, 0x30);	// CMD 0x30 means write sector

	for (; nsecs > 0; nsecs--, src += SECTSIZE) {
  800118:	83 ef 01             	sub    $0x1,%edi
  80011b:	74 08                	je     800125 <ide_write+0xb4>
  80011d:	81 c3 00 02 00 00    	add    $0x200,%ebx
  800123:	eb d6                	jmp    8000fb <ide_write+0x8a>
  800125:	b8 00 00 00 00       	mov    $0x0,%eax
			return r;
		outsl(0x1F0, src, SECTSIZE/4);
	}

	return 0;
}
  80012a:	83 c4 1c             	add    $0x1c,%esp
  80012d:	5b                   	pop    %ebx
  80012e:	5e                   	pop    %esi
  80012f:	5f                   	pop    %edi
  800130:	5d                   	pop    %ebp
  800131:	c3                   	ret    

00800132 <ide_read>:
	diskno = d;
}

int
ide_read(uint32_t secno, void *dst, size_t nsecs)
{
  800132:	55                   	push   %ebp
  800133:	89 e5                	mov    %esp,%ebp
  800135:	57                   	push   %edi
  800136:	56                   	push   %esi
  800137:	53                   	push   %ebx
  800138:	83 ec 1c             	sub    $0x1c,%esp
  80013b:	8b 7d 08             	mov    0x8(%ebp),%edi
  80013e:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800141:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	assert(nsecs <= 256);
  800144:	81 fe 00 01 00 00    	cmp    $0x100,%esi
  80014a:	76 24                	jbe    800170 <ide_read+0x3e>
  80014c:	c7 44 24 0c 60 46 80 	movl   $0x804660,0xc(%esp)
  800153:	00 
  800154:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  80015b:	00 
  80015c:	c7 44 24 04 43 00 00 	movl   $0x43,0x4(%esp)
  800163:	00 
  800164:	c7 04 24 82 46 80 00 	movl   $0x804682,(%esp)
  80016b:	e8 10 1d 00 00       	call   801e80 <_panic>

	ide_wait_ready(0);
  800170:	b8 00 00 00 00       	mov    $0x0,%eax
  800175:	e8 c6 fe ff ff       	call   800040 <ide_wait_ready>
}

static __inline void
outb(int port, uint8_t data)
{
	__asm __volatile("outb %0,%w1" : : "a" (data), "d" (port));
  80017a:	ba f2 01 00 00       	mov    $0x1f2,%edx
  80017f:	89 f0                	mov    %esi,%eax
  800181:	ee                   	out    %al,(%dx)
  800182:	b2 f3                	mov    $0xf3,%dl
  800184:	89 f8                	mov    %edi,%eax
  800186:	ee                   	out    %al,(%dx)
  800187:	89 f8                	mov    %edi,%eax
  800189:	c1 e8 08             	shr    $0x8,%eax
  80018c:	b2 f4                	mov    $0xf4,%dl
  80018e:	ee                   	out    %al,(%dx)
  80018f:	89 f8                	mov    %edi,%eax
  800191:	c1 e8 10             	shr    $0x10,%eax
  800194:	b2 f5                	mov    $0xf5,%dl
  800196:	ee                   	out    %al,(%dx)
  800197:	a1 00 90 80 00       	mov    0x809000,%eax
  80019c:	83 e0 01             	and    $0x1,%eax
  80019f:	c1 e0 04             	shl    $0x4,%eax
  8001a2:	83 c8 e0             	or     $0xffffffe0,%eax
  8001a5:	c1 ef 18             	shr    $0x18,%edi
  8001a8:	83 e7 0f             	and    $0xf,%edi
  8001ab:	09 f8                	or     %edi,%eax
  8001ad:	b2 f6                	mov    $0xf6,%dl
  8001af:	ee                   	out    %al,(%dx)
  8001b0:	b2 f7                	mov    $0xf7,%dl
  8001b2:	b8 20 00 00 00       	mov    $0x20,%eax
  8001b7:	ee                   	out    %al,(%dx)
	outb(0x1F4, (secno >> 8) & 0xFF);
	outb(0x1F5, (secno >> 16) & 0xFF);
	outb(0x1F6, 0xE0 | ((diskno&1)<<4) | ((secno>>24)&0x0F));
	outb(0x1F7, 0x20);	// CMD 0x20 means read sector

	for (; nsecs > 0; nsecs--, dst += SECTSIZE) {
  8001b8:	85 f6                	test   %esi,%esi
  8001ba:	74 2a                	je     8001e6 <ide_read+0xb4>
		if ((r = ide_wait_ready(1)) < 0)
  8001bc:	b8 01 00 00 00       	mov    $0x1,%eax
  8001c1:	e8 7a fe ff ff       	call   800040 <ide_wait_ready>
  8001c6:	85 c0                	test   %eax,%eax
  8001c8:	78 21                	js     8001eb <ide_read+0xb9>
}

static __inline void
insl(int port, void *addr, int cnt)
{
	__asm __volatile("cld\n\trepne\n\tinsl"			:
  8001ca:	89 df                	mov    %ebx,%edi
  8001cc:	b9 80 00 00 00       	mov    $0x80,%ecx
  8001d1:	ba f0 01 00 00       	mov    $0x1f0,%edx
  8001d6:	fc                   	cld    
  8001d7:	f2 6d                	repnz insl (%dx),%es:(%edi)
	outb(0x1F4, (secno >> 8) & 0xFF);
	outb(0x1F5, (secno >> 16) & 0xFF);
	outb(0x1F6, 0xE0 | ((diskno&1)<<4) | ((secno>>24)&0x0F));
	outb(0x1F7, 0x20);	// CMD 0x20 means read sector

	for (; nsecs > 0; nsecs--, dst += SECTSIZE) {
  8001d9:	83 ee 01             	sub    $0x1,%esi
  8001dc:	74 08                	je     8001e6 <ide_read+0xb4>
  8001de:	81 c3 00 02 00 00    	add    $0x200,%ebx
  8001e4:	eb d6                	jmp    8001bc <ide_read+0x8a>
  8001e6:	b8 00 00 00 00       	mov    $0x0,%eax
			return r;
		insl(0x1F0, dst, SECTSIZE/4);
	}
	
	return 0;
}
  8001eb:	83 c4 1c             	add    $0x1c,%esp
  8001ee:	5b                   	pop    %ebx
  8001ef:	5e                   	pop    %esi
  8001f0:	5f                   	pop    %edi
  8001f1:	5d                   	pop    %ebp
  8001f2:	c3                   	ret    

008001f3 <ide_set_disk>:
	return (x < 1000);
}

void
ide_set_disk(int d)
{
  8001f3:	55                   	push   %ebp
  8001f4:	89 e5                	mov    %esp,%ebp
  8001f6:	83 ec 18             	sub    $0x18,%esp
  8001f9:	8b 45 08             	mov    0x8(%ebp),%eax
	if (d != 0 && d != 1)
  8001fc:	83 f8 01             	cmp    $0x1,%eax
  8001ff:	76 1c                	jbe    80021d <ide_set_disk+0x2a>
		panic("bad disk number");
  800201:	c7 44 24 08 8b 46 80 	movl   $0x80468b,0x8(%esp)
  800208:	00 
  800209:	c7 44 24 04 3a 00 00 	movl   $0x3a,0x4(%esp)
  800210:	00 
  800211:	c7 04 24 82 46 80 00 	movl   $0x804682,(%esp)
  800218:	e8 63 1c 00 00       	call   801e80 <_panic>
	diskno = d;
  80021d:	a3 00 90 80 00       	mov    %eax,0x809000
}
  800222:	c9                   	leave  
  800223:	c3                   	ret    

00800224 <ide_probe_disk1>:
	return 0;
}

bool
ide_probe_disk1(void)
{
  800224:	55                   	push   %ebp
  800225:	89 e5                	mov    %esp,%ebp
  800227:	53                   	push   %ebx
  800228:	83 ec 14             	sub    $0x14,%esp
	int r, x;

	// wait for Device 0 to be ready
	ide_wait_ready(0);
  80022b:	b8 00 00 00 00       	mov    $0x0,%eax
  800230:	e8 0b fe ff ff       	call   800040 <ide_wait_ready>
}

static __inline void
outb(int port, uint8_t data)
{
	__asm __volatile("outb %0,%w1" : : "a" (data), "d" (port));
  800235:	ba f6 01 00 00       	mov    $0x1f6,%edx
  80023a:	b8 f0 ff ff ff       	mov    $0xfffffff0,%eax
  80023f:	ee                   	out    %al,(%dx)

static __inline uint8_t
inb(int port)
{
	uint8_t data;
	__asm __volatile("inb %w1,%0" : "=a" (data) : "d" (port));
  800240:	b2 f7                	mov    $0xf7,%dl
  800242:	ec                   	in     (%dx),%al

	// switch to Device 1
	outb(0x1F6, 0xE0 | (1<<4));

	// check for Device 1 to be ready for a while
	for (x = 0; 
  800243:	b9 01 00 00 00       	mov    $0x1,%ecx
  800248:	a8 a1                	test   $0xa1,%al
  80024a:	75 0f                	jne    80025b <ide_probe_disk1+0x37>
  80024c:	b1 00                	mov    $0x0,%cl
  80024e:	eb 10                	jmp    800260 <ide_probe_disk1+0x3c>
	     x < 1000 && ((r = inb(0x1F7)) & (IDE_BSY|IDE_DF|IDE_ERR)) != 0; 
	     x++)
  800250:	83 c1 01             	add    $0x1,%ecx

	// switch to Device 1
	outb(0x1F6, 0xE0 | (1<<4));

	// check for Device 1 to be ready for a while
	for (x = 0; 
  800253:	81 f9 e8 03 00 00    	cmp    $0x3e8,%ecx
  800259:	74 05                	je     800260 <ide_probe_disk1+0x3c>
  80025b:	ec                   	in     (%dx),%al
  80025c:	a8 a1                	test   $0xa1,%al
  80025e:	75 f0                	jne    800250 <ide_probe_disk1+0x2c>
}

static __inline void
outb(int port, uint8_t data)
{
	__asm __volatile("outb %0,%w1" : : "a" (data), "d" (port));
  800260:	ba f6 01 00 00       	mov    $0x1f6,%edx
  800265:	b8 e0 ff ff ff       	mov    $0xffffffe0,%eax
  80026a:	ee                   	out    %al,(%dx)
		/* do nothing */;

	// switch back to Device 0
	outb(0x1F6, 0xE0 | (0<<4));

	cprintf("Device 1 presence: %d\n", (x < 1000));
  80026b:	81 f9 e7 03 00 00    	cmp    $0x3e7,%ecx
  800271:	0f 9e c3             	setle  %bl
  800274:	0f b6 db             	movzbl %bl,%ebx
  800277:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80027b:	c7 04 24 9b 46 80 00 	movl   $0x80469b,(%esp)
  800282:	e8 be 1c 00 00       	call   801f45 <cprintf>
	return (x < 1000);
}
  800287:	89 d8                	mov    %ebx,%eax
  800289:	83 c4 14             	add    $0x14,%esp
  80028c:	5b                   	pop    %ebx
  80028d:	5d                   	pop    %ebp
  80028e:	c3                   	ret    
	...

00800290 <va_is_mapped>:
}

// Is this virtual address mapped?
bool
va_is_mapped(void *va)
{
  800290:	55                   	push   %ebp
  800291:	89 e5                	mov    %esp,%ebp
	return (vpd[PDX(va)] & PTE_P) && (vpt[VPN(va)] & PTE_P);
  800293:	8b 55 08             	mov    0x8(%ebp),%edx
  800296:	89 d0                	mov    %edx,%eax
  800298:	c1 e8 16             	shr    $0x16,%eax
  80029b:	8b 0c 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%ecx
  8002a2:	b8 00 00 00 00       	mov    $0x0,%eax
  8002a7:	f6 c1 01             	test   $0x1,%cl
  8002aa:	74 0d                	je     8002b9 <va_is_mapped+0x29>
  8002ac:	c1 ea 0c             	shr    $0xc,%edx
  8002af:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8002b6:	83 e0 01             	and    $0x1,%eax
}
  8002b9:	5d                   	pop    %ebp
  8002ba:	c3                   	ret    

008002bb <va_is_dirty>:

// Is this virtual address dirty?
bool
va_is_dirty(void *va)
{
  8002bb:	55                   	push   %ebp
  8002bc:	89 e5                	mov    %esp,%ebp
	return (vpt[VPN(va)] & PTE_D) != 0;
  8002be:	8b 45 08             	mov    0x8(%ebp),%eax
  8002c1:	c1 e8 0c             	shr    $0xc,%eax
  8002c4:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  8002cb:	c1 e8 06             	shr    $0x6,%eax
  8002ce:	83 e0 01             	and    $0x1,%eax
}
  8002d1:	5d                   	pop    %ebp
  8002d2:	c3                   	ret    

008002d3 <diskaddr>:
#include "fs.h"

// Return the virtual address of this disk block.
void*
diskaddr(uint32_t blockno)
{
  8002d3:	55                   	push   %ebp
  8002d4:	89 e5                	mov    %esp,%ebp
  8002d6:	83 ec 18             	sub    $0x18,%esp
  8002d9:	8b 45 08             	mov    0x8(%ebp),%eax
	if (blockno == 0 || (super && blockno >= super->s_nblocks))
  8002dc:	85 c0                	test   %eax,%eax
  8002de:	74 0f                	je     8002ef <diskaddr+0x1c>
  8002e0:	8b 15 dc d0 80 00    	mov    0x80d0dc,%edx
  8002e6:	85 d2                	test   %edx,%edx
  8002e8:	74 25                	je     80030f <diskaddr+0x3c>
  8002ea:	3b 42 04             	cmp    0x4(%edx),%eax
  8002ed:	72 20                	jb     80030f <diskaddr+0x3c>
		panic("bad block number %08x in diskaddr", blockno);
  8002ef:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002f3:	c7 44 24 08 b4 46 80 	movl   $0x8046b4,0x8(%esp)
  8002fa:	00 
  8002fb:	c7 44 24 04 09 00 00 	movl   $0x9,0x4(%esp)
  800302:	00 
  800303:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  80030a:	e8 71 1b 00 00       	call   801e80 <_panic>
  80030f:	05 00 00 01 00       	add    $0x10000,%eax
  800314:	c1 e0 0c             	shl    $0xc,%eax
	return (char*) (DISKMAP + blockno * BLKSIZE);
}
  800317:	c9                   	leave  
  800318:	c3                   	ret    

00800319 <bc_pgfault>:
// Fault any disk block that is read or written in to memory by
// loading it from disk.
// Hint: Use ide_read and BLKSECTS.
static void
bc_pgfault(struct UTrapframe *utf)
{
  800319:	55                   	push   %ebp
  80031a:	89 e5                	mov    %esp,%ebp
  80031c:	56                   	push   %esi
  80031d:	53                   	push   %ebx
  80031e:	83 ec 20             	sub    $0x20,%esp
  800321:	8b 45 08             	mov    0x8(%ebp),%eax
	void *addr = (void *) utf->utf_fault_va;
  800324:	8b 18                	mov    (%eax),%ebx
	uint32_t blockno = ((uint32_t)addr - DISKMAP) / BLKSIZE;
  void *alignedAddr = (void *)(DISKMAP + blockno*BLKSIZE);
	int r;

	// Check that the fault was within the block cache region
	if (addr < (void*)DISKMAP || addr >= (void*)(DISKMAP + DISKSIZE))
  800326:	8d 93 00 00 00 f0    	lea    -0x10000000(%ebx),%edx
  80032c:	81 fa ff ff ff bf    	cmp    $0xbfffffff,%edx
  800332:	76 2e                	jbe    800362 <bc_pgfault+0x49>
		panic("page fault in FS: eip %08x, va %08x, err %04x",
  800334:	8b 50 04             	mov    0x4(%eax),%edx
  800337:	89 54 24 14          	mov    %edx,0x14(%esp)
  80033b:	89 5c 24 10          	mov    %ebx,0x10(%esp)
  80033f:	8b 40 28             	mov    0x28(%eax),%eax
  800342:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800346:	c7 44 24 08 d8 46 80 	movl   $0x8046d8,0x8(%esp)
  80034d:	00 
  80034e:	c7 44 24 04 29 00 00 	movl   $0x29,0x4(%esp)
  800355:	00 
  800356:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  80035d:	e8 1e 1b 00 00       	call   801e80 <_panic>
// Hint: Use ide_read and BLKSECTS.
static void
bc_pgfault(struct UTrapframe *utf)
{
	void *addr = (void *) utf->utf_fault_va;
	uint32_t blockno = ((uint32_t)addr - DISKMAP) / BLKSIZE;
  800362:	81 eb 00 00 00 10    	sub    $0x10000000,%ebx
  800368:	c1 eb 0c             	shr    $0xc,%ebx
  void *alignedAddr = (void *)(DISKMAP + blockno*BLKSIZE);
  80036b:	8d b3 00 00 01 00    	lea    0x10000(%ebx),%esi
  800371:	c1 e6 0c             	shl    $0xc,%esi

	// Allocate a page in the disk map region and read the
	// contents of the block from the disk into that page.
	//
	// LAB 5: Your code here
  if ((r=sys_page_alloc(env->env_id, alignedAddr, PTE_P|PTE_U|PTE_W))<0)
  800374:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  800379:	8b 40 4c             	mov    0x4c(%eax),%eax
  80037c:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  800383:	00 
  800384:	89 74 24 04          	mov    %esi,0x4(%esp)
  800388:	89 04 24             	mov    %eax,(%esp)
  80038b:	e8 e6 29 00 00       	call   802d76 <sys_page_alloc>
  800390:	85 c0                	test   %eax,%eax
  800392:	79 20                	jns    8003b4 <bc_pgfault+0x9b>
      panic("bc_pgfault: page_alloc error: %e", r);
  800394:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800398:	c7 44 24 08 08 47 80 	movl   $0x804708,0x8(%esp)
  80039f:	00 
  8003a0:	c7 44 24 04 30 00 00 	movl   $0x30,0x4(%esp)
  8003a7:	00 
  8003a8:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  8003af:	e8 cc 1a 00 00       	call   801e80 <_panic>
  
  if ((r=ide_read(blockno*BLKSECTS, alignedAddr, BLKSECTS))<0) {
  8003b4:	c7 44 24 08 08 00 00 	movl   $0x8,0x8(%esp)
  8003bb:	00 
  8003bc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003c0:	8d 04 dd 00 00 00 00 	lea    0x0(,%ebx,8),%eax
  8003c7:	89 04 24             	mov    %eax,(%esp)
  8003ca:	e8 63 fd ff ff       	call   800132 <ide_read>
  8003cf:	85 c0                	test   %eax,%eax
  8003d1:	79 20                	jns    8003f3 <bc_pgfault+0xda>
      panic("bc_pgfault: ide_read error: %e", r);
  8003d3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8003d7:	c7 44 24 08 2c 47 80 	movl   $0x80472c,0x8(%esp)
  8003de:	00 
  8003df:	c7 44 24 04 33 00 00 	movl   $0x33,0x4(%esp)
  8003e6:	00 
  8003e7:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  8003ee:	e8 8d 1a 00 00       	call   801e80 <_panic>
  }

	// Sanity check the block number. (exercise for the reader:
	// why do we do this *after* reading the block in?)
	if (super && blockno >= super->s_nblocks)
  8003f3:	a1 dc d0 80 00       	mov    0x80d0dc,%eax
  8003f8:	85 c0                	test   %eax,%eax
  8003fa:	74 25                	je     800421 <bc_pgfault+0x108>
  8003fc:	3b 58 04             	cmp    0x4(%eax),%ebx
  8003ff:	72 20                	jb     800421 <bc_pgfault+0x108>
		panic("reading non-existent block %08x\n", blockno);
  800401:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800405:	c7 44 24 08 4c 47 80 	movl   $0x80474c,0x8(%esp)
  80040c:	00 
  80040d:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  800414:	00 
  800415:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  80041c:	e8 5f 1a 00 00       	call   801e80 <_panic>

	// Check that the block we read was allocated.
	if (bitmap && block_is_free(blockno))
  800421:	83 3d d8 d0 80 00 00 	cmpl   $0x0,0x80d0d8
  800428:	74 2c                	je     800456 <bc_pgfault+0x13d>
  80042a:	89 1c 24             	mov    %ebx,(%esp)
  80042d:	e8 ee 02 00 00       	call   800720 <block_is_free>
  800432:	85 c0                	test   %eax,%eax
  800434:	74 20                	je     800456 <bc_pgfault+0x13d>
		panic("reading free block %08x\n", blockno);
  800436:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80043a:	c7 44 24 08 e0 47 80 	movl   $0x8047e0,0x8(%esp)
  800441:	00 
  800442:	c7 44 24 04 3d 00 00 	movl   $0x3d,0x4(%esp)
  800449:	00 
  80044a:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  800451:	e8 2a 1a 00 00       	call   801e80 <_panic>
}
  800456:	83 c4 20             	add    $0x20,%esp
  800459:	5b                   	pop    %ebx
  80045a:	5e                   	pop    %esi
  80045b:	5d                   	pop    %ebp
  80045c:	c3                   	ret    

0080045d <flush_block>:
// Hint: Use va_is_mapped, va_is_dirty, and ide_write.
// Hint: Use the PTE_USER constant when calling sys_page_map.
// Hint: Don't forget to round addr down.
void
flush_block(void *addr)
{
  80045d:	55                   	push   %ebp
  80045e:	89 e5                	mov    %esp,%ebp
  800460:	83 ec 28             	sub    $0x28,%esp
  800463:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800466:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800469:	8b 5d 08             	mov    0x8(%ebp),%ebx
	uint32_t blockno = ((uint32_t)addr - DISKMAP) / BLKSIZE;
  void *alignedAddr = (void *)(((int)addr>>PGSHIFT)<<PGSHIFT);
  int r;

	if (addr < (void*)DISKMAP || addr >= (void*)(DISKMAP + DISKSIZE))
  80046c:	8d 83 00 00 00 f0    	lea    -0x10000000(%ebx),%eax
  800472:	3d ff ff ff bf       	cmp    $0xbfffffff,%eax
  800477:	76 20                	jbe    800499 <flush_block+0x3c>
		panic("flush_block of bad va %08x", addr);
  800479:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80047d:	c7 44 24 08 f9 47 80 	movl   $0x8047f9,0x8(%esp)
  800484:	00 
  800485:	c7 44 24 04 4f 00 00 	movl   $0x4f,0x4(%esp)
  80048c:	00 
  80048d:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  800494:	e8 e7 19 00 00       	call   801e80 <_panic>

  if (va_is_dirty(addr)) {
  800499:	89 1c 24             	mov    %ebx,(%esp)
  80049c:	e8 1a fe ff ff       	call   8002bb <va_is_dirty>
  8004a1:	85 c0                	test   %eax,%eax
  8004a3:	0f 84 97 00 00 00    	je     800540 <flush_block+0xe3>
// Hint: Don't forget to round addr down.
void
flush_block(void *addr)
{
	uint32_t blockno = ((uint32_t)addr - DISKMAP) / BLKSIZE;
  void *alignedAddr = (void *)(((int)addr>>PGSHIFT)<<PGSHIFT);
  8004a9:	89 de                	mov    %ebx,%esi
  8004ab:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi

	if (addr < (void*)DISKMAP || addr >= (void*)(DISKMAP + DISKSIZE))
		panic("flush_block of bad va %08x", addr);

  if (va_is_dirty(addr)) {
    if ((r=ide_write(blockno*BLKSECTS, alignedAddr, BLKSECTS))<0)
  8004b1:	c7 44 24 08 08 00 00 	movl   $0x8,0x8(%esp)
  8004b8:	00 
  8004b9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8004bd:	81 eb 00 00 00 10    	sub    $0x10000000,%ebx
  8004c3:	c1 eb 0c             	shr    $0xc,%ebx
  8004c6:	c1 e3 03             	shl    $0x3,%ebx
  8004c9:	89 1c 24             	mov    %ebx,(%esp)
  8004cc:	e8 a0 fb ff ff       	call   800071 <ide_write>
  8004d1:	85 c0                	test   %eax,%eax
  8004d3:	79 20                	jns    8004f5 <flush_block+0x98>
      panic("flush_block ide_write error: %e", r);
  8004d5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8004d9:	c7 44 24 08 70 47 80 	movl   $0x804770,0x8(%esp)
  8004e0:	00 
  8004e1:	c7 44 24 04 53 00 00 	movl   $0x53,0x4(%esp)
  8004e8:	00 
  8004e9:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  8004f0:	e8 8b 19 00 00       	call   801e80 <_panic>

    if ((r=sys_page_map(env->env_id, alignedAddr, env->env_id, alignedAddr, PTE_P|PTE_U|PTE_W))<0)
  8004f5:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  8004fa:	8b 50 4c             	mov    0x4c(%eax),%edx
  8004fd:	8b 40 4c             	mov    0x4c(%eax),%eax
  800500:	c7 44 24 10 07 00 00 	movl   $0x7,0x10(%esp)
  800507:	00 
  800508:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80050c:	89 54 24 08          	mov    %edx,0x8(%esp)
  800510:	89 74 24 04          	mov    %esi,0x4(%esp)
  800514:	89 04 24             	mov    %eax,(%esp)
  800517:	e8 fc 27 00 00       	call   802d18 <sys_page_map>
  80051c:	85 c0                	test   %eax,%eax
  80051e:	79 20                	jns    800540 <flush_block+0xe3>
      panic("flush_block sys_page_map error: %e", r);
  800520:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800524:	c7 44 24 08 90 47 80 	movl   $0x804790,0x8(%esp)
  80052b:	00 
  80052c:	c7 44 24 04 56 00 00 	movl   $0x56,0x4(%esp)
  800533:	00 
  800534:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  80053b:	e8 40 19 00 00       	call   801e80 <_panic>
  }
}
  800540:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800543:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800546:	89 ec                	mov    %ebp,%esp
  800548:	5d                   	pop    %ebp
  800549:	c3                   	ret    

0080054a <check_bc>:

// Test that the block cache works, by smashing the superblock and
// reading it back.
static void
check_bc(void)
{
  80054a:	55                   	push   %ebp
  80054b:	89 e5                	mov    %esp,%ebp
  80054d:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct Super backup;

	// back up super block
	memmove(&backup, diskaddr(1), sizeof backup);
  800553:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  80055a:	e8 74 fd ff ff       	call   8002d3 <diskaddr>
  80055f:	c7 44 24 08 08 01 00 	movl   $0x108,0x8(%esp)
  800566:	00 
  800567:	89 44 24 04          	mov    %eax,0x4(%esp)
  80056b:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800571:	89 04 24             	mov    %eax,(%esp)
  800574:	e8 5c 22 00 00       	call   8027d5 <memmove>

	// smash it 
	strcpy(diskaddr(1), "OOPS!\n");
  800579:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  800580:	e8 4e fd ff ff       	call   8002d3 <diskaddr>
  800585:	c7 44 24 04 14 48 80 	movl   $0x804814,0x4(%esp)
  80058c:	00 
  80058d:	89 04 24             	mov    %eax,(%esp)
  800590:	e8 85 20 00 00       	call   80261a <strcpy>
	flush_block(diskaddr(1));
  800595:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  80059c:	e8 32 fd ff ff       	call   8002d3 <diskaddr>
  8005a1:	89 04 24             	mov    %eax,(%esp)
  8005a4:	e8 b4 fe ff ff       	call   80045d <flush_block>
	assert(va_is_mapped(diskaddr(1)));
  8005a9:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8005b0:	e8 1e fd ff ff       	call   8002d3 <diskaddr>
  8005b5:	89 04 24             	mov    %eax,(%esp)
  8005b8:	e8 d3 fc ff ff       	call   800290 <va_is_mapped>
  8005bd:	85 c0                	test   %eax,%eax
  8005bf:	75 24                	jne    8005e5 <check_bc+0x9b>
  8005c1:	c7 44 24 0c 36 48 80 	movl   $0x804836,0xc(%esp)
  8005c8:	00 
  8005c9:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  8005d0:	00 
  8005d1:	c7 44 24 04 67 00 00 	movl   $0x67,0x4(%esp)
  8005d8:	00 
  8005d9:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  8005e0:	e8 9b 18 00 00       	call   801e80 <_panic>
	assert(!va_is_dirty(diskaddr(1)));
  8005e5:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8005ec:	e8 e2 fc ff ff       	call   8002d3 <diskaddr>
  8005f1:	89 04 24             	mov    %eax,(%esp)
  8005f4:	e8 c2 fc ff ff       	call   8002bb <va_is_dirty>
  8005f9:	85 c0                	test   %eax,%eax
  8005fb:	74 24                	je     800621 <check_bc+0xd7>
  8005fd:	c7 44 24 0c 1b 48 80 	movl   $0x80481b,0xc(%esp)
  800604:	00 
  800605:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  80060c:	00 
  80060d:	c7 44 24 04 68 00 00 	movl   $0x68,0x4(%esp)
  800614:	00 
  800615:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  80061c:	e8 5f 18 00 00       	call   801e80 <_panic>

	// clear it out
	sys_page_unmap(0, diskaddr(1));
  800621:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  800628:	e8 a6 fc ff ff       	call   8002d3 <diskaddr>
  80062d:	89 44 24 04          	mov    %eax,0x4(%esp)
  800631:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800638:	e8 7d 26 00 00       	call   802cba <sys_page_unmap>
	assert(!va_is_mapped(diskaddr(1)));
  80063d:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  800644:	e8 8a fc ff ff       	call   8002d3 <diskaddr>
  800649:	89 04 24             	mov    %eax,(%esp)
  80064c:	e8 3f fc ff ff       	call   800290 <va_is_mapped>
  800651:	85 c0                	test   %eax,%eax
  800653:	74 24                	je     800679 <check_bc+0x12f>
  800655:	c7 44 24 0c 35 48 80 	movl   $0x804835,0xc(%esp)
  80065c:	00 
  80065d:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  800664:	00 
  800665:	c7 44 24 04 6c 00 00 	movl   $0x6c,0x4(%esp)
  80066c:	00 
  80066d:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  800674:	e8 07 18 00 00       	call   801e80 <_panic>

	// read it back in
	assert(strcmp(diskaddr(1), "OOPS!\n") == 0);
  800679:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  800680:	e8 4e fc ff ff       	call   8002d3 <diskaddr>
  800685:	c7 44 24 04 14 48 80 	movl   $0x804814,0x4(%esp)
  80068c:	00 
  80068d:	89 04 24             	mov    %eax,(%esp)
  800690:	e8 14 20 00 00       	call   8026a9 <strcmp>
  800695:	85 c0                	test   %eax,%eax
  800697:	74 24                	je     8006bd <check_bc+0x173>
  800699:	c7 44 24 0c b4 47 80 	movl   $0x8047b4,0xc(%esp)
  8006a0:	00 
  8006a1:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  8006a8:	00 
  8006a9:	c7 44 24 04 6f 00 00 	movl   $0x6f,0x4(%esp)
  8006b0:	00 
  8006b1:	c7 04 24 d8 47 80 00 	movl   $0x8047d8,(%esp)
  8006b8:	e8 c3 17 00 00       	call   801e80 <_panic>

	// fix it
	memmove(diskaddr(1), &backup, sizeof backup);
  8006bd:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8006c4:	e8 0a fc ff ff       	call   8002d3 <diskaddr>
  8006c9:	c7 44 24 08 08 01 00 	movl   $0x108,0x8(%esp)
  8006d0:	00 
  8006d1:	8d 95 f0 fe ff ff    	lea    -0x110(%ebp),%edx
  8006d7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8006db:	89 04 24             	mov    %eax,(%esp)
  8006de:	e8 f2 20 00 00       	call   8027d5 <memmove>
	flush_block(diskaddr(1));
  8006e3:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  8006ea:	e8 e4 fb ff ff       	call   8002d3 <diskaddr>
  8006ef:	89 04 24             	mov    %eax,(%esp)
  8006f2:	e8 66 fd ff ff       	call   80045d <flush_block>

	cprintf("block cache is good\n");
  8006f7:	c7 04 24 50 48 80 00 	movl   $0x804850,(%esp)
  8006fe:	e8 42 18 00 00       	call   801f45 <cprintf>
}
  800703:	c9                   	leave  
  800704:	c3                   	ret    

00800705 <bc_init>:

void
bc_init(void)
{
  800705:	55                   	push   %ebp
  800706:	89 e5                	mov    %esp,%ebp
  800708:	83 ec 18             	sub    $0x18,%esp
	set_pgfault_handler(bc_pgfault);
  80070b:	c7 04 24 19 03 80 00 	movl   $0x800319,(%esp)
  800712:	e8 85 27 00 00       	call   802e9c <set_pgfault_handler>
	check_bc();
  800717:	e8 2e fe ff ff       	call   80054a <check_bc>
}
  80071c:	c9                   	leave  
  80071d:	c3                   	ret    
	...

00800720 <block_is_free>:

// Check to see if the block bitmap indicates that block 'blockno' is free.
// Return 1 if the block is free, 0 if not.
bool
block_is_free(uint32_t blockno)
{
  800720:	55                   	push   %ebp
  800721:	89 e5                	mov    %esp,%ebp
  800723:	53                   	push   %ebx
  800724:	8b 45 08             	mov    0x8(%ebp),%eax
	if (super == 0 || blockno >= super->s_nblocks)
  800727:	8b 15 dc d0 80 00    	mov    0x80d0dc,%edx
  80072d:	85 d2                	test   %edx,%edx
  80072f:	74 25                	je     800756 <block_is_free+0x36>
  800731:	39 42 04             	cmp    %eax,0x4(%edx)
  800734:	76 20                	jbe    800756 <block_is_free+0x36>
  800736:	89 c1                	mov    %eax,%ecx
  800738:	83 e1 1f             	and    $0x1f,%ecx
  80073b:	ba 01 00 00 00       	mov    $0x1,%edx
  800740:	d3 e2                	shl    %cl,%edx
  800742:	c1 e8 05             	shr    $0x5,%eax
  800745:	8b 1d d8 d0 80 00    	mov    0x80d0d8,%ebx
  80074b:	85 14 83             	test   %edx,(%ebx,%eax,4)
  80074e:	0f 95 c0             	setne  %al
  800751:	0f b6 c0             	movzbl %al,%eax
  800754:	eb 05                	jmp    80075b <block_is_free+0x3b>
  800756:	b8 00 00 00 00       	mov    $0x0,%eax
		return 0;
	if (bitmap[blockno / 32] & (1 << (blockno % 32)))
		return 1;
	return 0;
}
  80075b:	5b                   	pop    %ebx
  80075c:	5d                   	pop    %ebp
  80075d:	c3                   	ret    

0080075e <skip_slash>:
}

// Skip over slashes.
static const char*
skip_slash(const char *p)
{
  80075e:	55                   	push   %ebp
  80075f:	89 e5                	mov    %esp,%ebp
	while (*p == '/')
  800761:	80 38 2f             	cmpb   $0x2f,(%eax)
  800764:	75 08                	jne    80076e <skip_slash+0x10>
		p++;
  800766:	83 c0 01             	add    $0x1,%eax

// Skip over slashes.
static const char*
skip_slash(const char *p)
{
	while (*p == '/')
  800769:	80 38 2f             	cmpb   $0x2f,(%eax)
  80076c:	74 f8                	je     800766 <skip_slash+0x8>
		p++;
	return p;
}
  80076e:	5d                   	pop    %ebp
  80076f:	c3                   	ret    

00800770 <fs_sync>:
}

// Sync the entire file system.  A big hammer.
void
fs_sync(void)
{
  800770:	55                   	push   %ebp
  800771:	89 e5                	mov    %esp,%ebp
  800773:	53                   	push   %ebx
  800774:	83 ec 14             	sub    $0x14,%esp
	int i;
	for (i = 1; i < super->s_nblocks; i++)
  800777:	a1 dc d0 80 00       	mov    0x80d0dc,%eax
  80077c:	83 78 04 01          	cmpl   $0x1,0x4(%eax)
  800780:	76 2a                	jbe    8007ac <fs_sync+0x3c>
  800782:	b8 01 00 00 00       	mov    $0x1,%eax
  800787:	bb 01 00 00 00       	mov    $0x1,%ebx
		flush_block(diskaddr(i));
  80078c:	89 04 24             	mov    %eax,(%esp)
  80078f:	e8 3f fb ff ff       	call   8002d3 <diskaddr>
  800794:	89 04 24             	mov    %eax,(%esp)
  800797:	e8 c1 fc ff ff       	call   80045d <flush_block>
// Sync the entire file system.  A big hammer.
void
fs_sync(void)
{
	int i;
	for (i = 1; i < super->s_nblocks; i++)
  80079c:	83 c3 01             	add    $0x1,%ebx
  80079f:	89 d8                	mov    %ebx,%eax
  8007a1:	8b 15 dc d0 80 00    	mov    0x80d0dc,%edx
  8007a7:	39 5a 04             	cmp    %ebx,0x4(%edx)
  8007aa:	77 e0                	ja     80078c <fs_sync+0x1c>
		flush_block(diskaddr(i));
}
  8007ac:	83 c4 14             	add    $0x14,%esp
  8007af:	5b                   	pop    %ebx
  8007b0:	5d                   	pop    %ebp
  8007b1:	c3                   	ret    

008007b2 <alloc_block>:
// -E_NO_DISK if we are out of blocks.
//
// Hint: use free_block as an example for manipulating the bitmap.
int
alloc_block(void)
{
  8007b2:	55                   	push   %ebp
  8007b3:	89 e5                	mov    %esp,%ebp
  8007b5:	56                   	push   %esi
  8007b6:	53                   	push   %ebx
  8007b7:	83 ec 10             	sub    $0x10,%esp
  int r;
	// The bitmap consists of one or more blocks.  A single bitmap block
	// contains the in-use bits for BLKBITSIZE blocks.  There are
	// super->s_nblocks blocks in the disk altogether.

  for (i=2; i<super->s_nblocks;i++) {
  8007ba:	a1 dc d0 80 00       	mov    0x80d0dc,%eax
  8007bf:	8b 70 04             	mov    0x4(%eax),%esi
  8007c2:	83 fe 02             	cmp    $0x2,%esi
  8007c5:	76 6f                	jbe    800836 <alloc_block+0x84>
  8007c7:	b8 02 00 00 00       	mov    $0x2,%eax
  8007cc:	bb 02 00 00 00       	mov    $0x2,%ebx
    if (block_is_free(i)) {
  8007d1:	89 04 24             	mov    %eax,(%esp)
  8007d4:	e8 47 ff ff ff       	call   800720 <block_is_free>
  8007d9:	85 c0                	test   %eax,%eax
  8007db:	74 50                	je     80082d <alloc_block+0x7b>
      bitmap[i/32]  &= ~(1<<(i%32));
  8007dd:	8d 43 1f             	lea    0x1f(%ebx),%eax
  8007e0:	85 db                	test   %ebx,%ebx
  8007e2:	0f 49 c3             	cmovns %ebx,%eax
  8007e5:	c1 f8 05             	sar    $0x5,%eax
  8007e8:	c1 e0 02             	shl    $0x2,%eax
  8007eb:	03 05 d8 d0 80 00    	add    0x80d0d8,%eax
  8007f1:	89 de                	mov    %ebx,%esi
  8007f3:	c1 fe 1f             	sar    $0x1f,%esi
  8007f6:	c1 ee 1b             	shr    $0x1b,%esi
  8007f9:	8d 0c 33             	lea    (%ebx,%esi,1),%ecx
  8007fc:	83 e1 1f             	and    $0x1f,%ecx
  8007ff:	29 f1                	sub    %esi,%ecx
  800801:	ba fe ff ff ff       	mov    $0xfffffffe,%edx
  800806:	d3 c2                	rol    %cl,%edx
  800808:	21 10                	and    %edx,(%eax)
      flush_block(diskaddr(2+(i/BLKBITSIZE)));
  80080a:	8d 83 ff 7f 00 00    	lea    0x7fff(%ebx),%eax
  800810:	85 db                	test   %ebx,%ebx
  800812:	0f 49 c3             	cmovns %ebx,%eax
  800815:	c1 f8 0f             	sar    $0xf,%eax
  800818:	83 c0 02             	add    $0x2,%eax
  80081b:	89 04 24             	mov    %eax,(%esp)
  80081e:	e8 b0 fa ff ff       	call   8002d3 <diskaddr>
  800823:	89 04 24             	mov    %eax,(%esp)
  800826:	e8 32 fc ff ff       	call   80045d <flush_block>
      return i;
  80082b:	eb 0e                	jmp    80083b <alloc_block+0x89>
  int r;
	// The bitmap consists of one or more blocks.  A single bitmap block
	// contains the in-use bits for BLKBITSIZE blocks.  There are
	// super->s_nblocks blocks in the disk altogether.

  for (i=2; i<super->s_nblocks;i++) {
  80082d:	83 c3 01             	add    $0x1,%ebx
  800830:	89 d8                	mov    %ebx,%eax
  800832:	39 f3                	cmp    %esi,%ebx
  800834:	72 9b                	jb     8007d1 <alloc_block+0x1f>
  800836:	bb f7 ff ff ff       	mov    $0xfffffff7,%ebx
      flush_block(diskaddr(2+(i/BLKBITSIZE)));
      return i;
    }
  }
	return -E_NO_DISK;
}
  80083b:	89 d8                	mov    %ebx,%eax
  80083d:	83 c4 10             	add    $0x10,%esp
  800840:	5b                   	pop    %ebx
  800841:	5e                   	pop    %esi
  800842:	5d                   	pop    %ebp
  800843:	c3                   	ret    

00800844 <free_block>:
}

// Mark a block free in the bitmap
void
free_block(uint32_t blockno)
{
  800844:	55                   	push   %ebp
  800845:	89 e5                	mov    %esp,%ebp
  800847:	83 ec 18             	sub    $0x18,%esp
  80084a:	8b 4d 08             	mov    0x8(%ebp),%ecx
	// Blockno zero is the null pointer of block numbers.
	if (blockno == 0)
  80084d:	85 c9                	test   %ecx,%ecx
  80084f:	75 1c                	jne    80086d <free_block+0x29>
		panic("attempt to free zero block");
  800851:	c7 44 24 08 65 48 80 	movl   $0x804865,0x8(%esp)
  800858:	00 
  800859:	c7 44 24 04 2c 00 00 	movl   $0x2c,0x4(%esp)
  800860:	00 
  800861:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  800868:	e8 13 16 00 00       	call   801e80 <_panic>
	bitmap[blockno/32] |= 1<<(blockno%32);
  80086d:	89 c8                	mov    %ecx,%eax
  80086f:	c1 e8 05             	shr    $0x5,%eax
  800872:	c1 e0 02             	shl    $0x2,%eax
  800875:	03 05 d8 d0 80 00    	add    0x80d0d8,%eax
  80087b:	83 e1 1f             	and    $0x1f,%ecx
  80087e:	ba 01 00 00 00       	mov    $0x1,%edx
  800883:	d3 e2                	shl    %cl,%edx
  800885:	09 10                	or     %edx,(%eax)
}
  800887:	c9                   	leave  
  800888:	c3                   	ret    

00800889 <check_bitmap>:
//
// Check that all reserved blocks -- 0, 1, and the bitmap blocks themselves --
// are all marked as in-use.
void
check_bitmap(void)
{
  800889:	55                   	push   %ebp
  80088a:	89 e5                	mov    %esp,%ebp
  80088c:	56                   	push   %esi
  80088d:	53                   	push   %ebx
  80088e:	83 ec 10             	sub    $0x10,%esp
	uint32_t i;

	// Make sure all bitmap blocks are marked in-use
	for (i = 0; i * BLKBITSIZE < super->s_nblocks; i++)
  800891:	a1 dc d0 80 00       	mov    0x80d0dc,%eax
  800896:	8b 70 04             	mov    0x4(%eax),%esi
  800899:	85 f6                	test   %esi,%esi
  80089b:	74 44                	je     8008e1 <check_bitmap+0x58>
  80089d:	bb 00 00 00 00       	mov    $0x0,%ebx
		assert(!block_is_free(2+i));
  8008a2:	8d 43 02             	lea    0x2(%ebx),%eax
  8008a5:	89 04 24             	mov    %eax,(%esp)
  8008a8:	e8 73 fe ff ff       	call   800720 <block_is_free>
  8008ad:	85 c0                	test   %eax,%eax
  8008af:	74 24                	je     8008d5 <check_bitmap+0x4c>
  8008b1:	c7 44 24 0c 88 48 80 	movl   $0x804888,0xc(%esp)
  8008b8:	00 
  8008b9:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  8008c0:	00 
  8008c1:	c7 44 24 04 56 00 00 	movl   $0x56,0x4(%esp)
  8008c8:	00 
  8008c9:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  8008d0:	e8 ab 15 00 00       	call   801e80 <_panic>
check_bitmap(void)
{
	uint32_t i;

	// Make sure all bitmap blocks are marked in-use
	for (i = 0; i * BLKBITSIZE < super->s_nblocks; i++)
  8008d5:	83 c3 01             	add    $0x1,%ebx
  8008d8:	89 d8                	mov    %ebx,%eax
  8008da:	c1 e0 0f             	shl    $0xf,%eax
  8008dd:	39 f0                	cmp    %esi,%eax
  8008df:	72 c1                	jb     8008a2 <check_bitmap+0x19>
		assert(!block_is_free(2+i));

	// Make sure the reserved and root blocks are marked in-use.
	assert(!block_is_free(0));
  8008e1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8008e8:	e8 33 fe ff ff       	call   800720 <block_is_free>
  8008ed:	85 c0                	test   %eax,%eax
  8008ef:	74 24                	je     800915 <check_bitmap+0x8c>
  8008f1:	c7 44 24 0c 9c 48 80 	movl   $0x80489c,0xc(%esp)
  8008f8:	00 
  8008f9:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  800900:	00 
  800901:	c7 44 24 04 59 00 00 	movl   $0x59,0x4(%esp)
  800908:	00 
  800909:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  800910:	e8 6b 15 00 00       	call   801e80 <_panic>
	assert(!block_is_free(1));
  800915:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  80091c:	e8 ff fd ff ff       	call   800720 <block_is_free>
  800921:	85 c0                	test   %eax,%eax
  800923:	74 24                	je     800949 <check_bitmap+0xc0>
  800925:	c7 44 24 0c ae 48 80 	movl   $0x8048ae,0xc(%esp)
  80092c:	00 
  80092d:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  800934:	00 
  800935:	c7 44 24 04 5a 00 00 	movl   $0x5a,0x4(%esp)
  80093c:	00 
  80093d:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  800944:	e8 37 15 00 00       	call   801e80 <_panic>

	cprintf("bitmap is good\n");
  800949:	c7 04 24 c0 48 80 00 	movl   $0x8048c0,(%esp)
  800950:	e8 f0 15 00 00       	call   801f45 <cprintf>
}
  800955:	83 c4 10             	add    $0x10,%esp
  800958:	5b                   	pop    %ebx
  800959:	5e                   	pop    %esi
  80095a:	5d                   	pop    %ebp
  80095b:	c3                   	ret    

0080095c <check_super>:
// --------------------------------------------------------------

// Validate the file system super-block.
void
check_super(void)
{
  80095c:	55                   	push   %ebp
  80095d:	89 e5                	mov    %esp,%ebp
  80095f:	83 ec 18             	sub    $0x18,%esp
	if (super->s_magic != FS_MAGIC)
  800962:	a1 dc d0 80 00       	mov    0x80d0dc,%eax
  800967:	81 38 ae 30 05 4a    	cmpl   $0x4a0530ae,(%eax)
  80096d:	74 1c                	je     80098b <check_super+0x2f>
		panic("bad file system magic number");
  80096f:	c7 44 24 08 d0 48 80 	movl   $0x8048d0,0x8(%esp)
  800976:	00 
  800977:	c7 44 24 04 0e 00 00 	movl   $0xe,0x4(%esp)
  80097e:	00 
  80097f:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  800986:	e8 f5 14 00 00       	call   801e80 <_panic>

	if (super->s_nblocks > DISKSIZE/BLKSIZE)
  80098b:	81 78 04 00 00 0c 00 	cmpl   $0xc0000,0x4(%eax)
  800992:	76 1c                	jbe    8009b0 <check_super+0x54>
		panic("file system is too large");
  800994:	c7 44 24 08 ed 48 80 	movl   $0x8048ed,0x8(%esp)
  80099b:	00 
  80099c:	c7 44 24 04 11 00 00 	movl   $0x11,0x4(%esp)
  8009a3:	00 
  8009a4:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  8009ab:	e8 d0 14 00 00       	call   801e80 <_panic>

	cprintf("superblock is good\n");
  8009b0:	c7 04 24 06 49 80 00 	movl   $0x804906,(%esp)
  8009b7:	e8 89 15 00 00       	call   801f45 <cprintf>
}
  8009bc:	c9                   	leave  
  8009bd:	c3                   	ret    

008009be <file_block_walk>:
//
// Analogy: This is like pgdir_walk for files.  
// Hint: Don't forget to clear any block you allocate.
static int
file_block_walk(struct File *f, uint32_t filebno, uint32_t **ppdiskbno, bool alloc)
{
  8009be:	55                   	push   %ebp
  8009bf:	89 e5                	mov    %esp,%ebp
  8009c1:	83 ec 48             	sub    $0x48,%esp
  8009c4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8009c7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8009ca:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8009cd:	89 c3                	mov    %eax,%ebx
  8009cf:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8009d2:	89 cf                	mov    %ecx,%edi
    int new_block   = 0;
    int r   = 0;

    if (!f || !ppdiskbno || filebno >= NDIRECT+NINDIRECT)
  8009d4:	85 c0                	test   %eax,%eax
  8009d6:	0f 84 d8 00 00 00    	je     800ab4 <file_block_walk+0xf6>
  8009dc:	85 c9                	test   %ecx,%ecx
  8009de:	0f 84 d0 00 00 00    	je     800ab4 <file_block_walk+0xf6>
  8009e4:	81 fa 09 04 00 00    	cmp    $0x409,%edx
  8009ea:	0f 87 c4 00 00 00    	ja     800ab4 <file_block_walk+0xf6>
        return -E_INVAL;

    *ppdiskbno  = 0;
  8009f0:	c7 01 00 00 00 00    	movl   $0x0,(%ecx)
    if (filebno < NDIRECT) {
  8009f6:	83 fa 09             	cmp    $0x9,%edx
  8009f9:	77 13                	ja     800a0e <file_block_walk+0x50>
        *ppdiskbno  = &f->f_direct[filebno];
  8009fb:	8d 84 90 88 00 00 00 	lea    0x88(%eax,%edx,4),%eax
  800a02:	89 01                	mov    %eax,(%ecx)
  800a04:	be 00 00 00 00       	mov    $0x0,%esi
  800a09:	e9 ab 00 00 00       	jmp    800ab9 <file_block_walk+0xfb>
    } else {
        if (!f->f_indirect && !alloc) {
  800a0e:	83 b8 b0 00 00 00 00 	cmpl   $0x0,0xb0(%eax)
  800a15:	0f 94 c0             	sete   %al
  800a18:	75 0f                	jne    800a29 <file_block_walk+0x6b>
  800a1a:	be f5 ff ff ff       	mov    $0xfffffff5,%esi
  800a1f:	83 7d 08 00          	cmpl   $0x0,0x8(%ebp)
  800a23:	0f 84 90 00 00 00    	je     800ab9 <file_block_walk+0xfb>
            return -E_NOT_FOUND;
        } else if (!f->f_indirect){
  800a29:	84 c0                	test   %al,%al
  800a2b:	74 69                	je     800a96 <file_block_walk+0xd8>
            int i_block = alloc_block();
  800a2d:	8d 76 00             	lea    0x0(%esi),%esi
  800a30:	e8 7d fd ff ff       	call   8007b2 <alloc_block>
  800a35:	89 c6                	mov    %eax,%esi
            if (i_block < 0)
  800a37:	85 c0                	test   %eax,%eax
  800a39:	78 7e                	js     800ab9 <file_block_walk+0xfb>
                return i_block; 
            memset(diskaddr(i_block), 0, BLKSIZE);
  800a3b:	89 04 24             	mov    %eax,(%esp)
  800a3e:	e8 90 f8 ff ff       	call   8002d3 <diskaddr>
  800a43:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  800a4a:	00 
  800a4b:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800a52:	00 
  800a53:	89 04 24             	mov    %eax,(%esp)
  800a56:	e8 1b 1d 00 00       	call   802776 <memset>
            f->f_indirect   = i_block;
  800a5b:	89 b3 b0 00 00 00    	mov    %esi,0xb0(%ebx)
            if ((r=sys_page_map(0, (void *)f, 0, (void *)f, vpt[VPN(f)]|PTE_D))<0)
  800a61:	89 d8                	mov    %ebx,%eax
  800a63:	c1 e8 0c             	shr    $0xc,%eax
  800a66:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  800a6d:	83 c8 40             	or     $0x40,%eax
  800a70:	89 44 24 10          	mov    %eax,0x10(%esp)
  800a74:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800a78:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  800a7f:	00 
  800a80:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800a84:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800a8b:	e8 88 22 00 00       	call   802d18 <sys_page_map>
  800a90:	89 c6                	mov    %eax,%esi
  800a92:	85 c0                	test   %eax,%eax
  800a94:	78 23                	js     800ab9 <file_block_walk+0xfb>
                return r;
        }
        *ppdiskbno  = &(((uint32_t *)diskaddr(f->f_indirect))[filebno-NDIRECT]);
  800a96:	8b 83 b0 00 00 00    	mov    0xb0(%ebx),%eax
  800a9c:	89 04 24             	mov    %eax,(%esp)
  800a9f:	e8 2f f8 ff ff       	call   8002d3 <diskaddr>
  800aa4:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800aa7:	8d 44 90 d8          	lea    -0x28(%eax,%edx,4),%eax
  800aab:	89 07                	mov    %eax,(%edi)
  800aad:	be 00 00 00 00       	mov    $0x0,%esi
  800ab2:	eb 05                	jmp    800ab9 <file_block_walk+0xfb>
  800ab4:	be fd ff ff ff       	mov    $0xfffffffd,%esi
    }
    return 0;
}
  800ab9:	89 f0                	mov    %esi,%eax
  800abb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800abe:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ac1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ac4:	89 ec                	mov    %ebp,%esp
  800ac6:	5d                   	pop    %ebp
  800ac7:	c3                   	ret    

00800ac8 <file_truncate_blocks>:
// (Remember to clear the f->f_indirect pointer so you'll know
// whether it's valid!)
// Do not change f->f_size.
static void
file_truncate_blocks(struct File *f, off_t newsize)
{
  800ac8:	55                   	push   %ebp
  800ac9:	89 e5                	mov    %esp,%ebp
  800acb:	57                   	push   %edi
  800acc:	56                   	push   %esi
  800acd:	53                   	push   %ebx
  800ace:	83 ec 3c             	sub    $0x3c,%esp
  800ad1:	89 c6                	mov    %eax,%esi
	int r;
	uint32_t bno, old_nblocks, new_nblocks;

	old_nblocks = (f->f_size + BLKSIZE - 1) / BLKSIZE;
  800ad3:	8b b8 80 00 00 00    	mov    0x80(%eax),%edi
  800ad9:	8d 87 fe 1f 00 00    	lea    0x1ffe(%edi),%eax
  800adf:	81 c7 ff 0f 00 00    	add    $0xfff,%edi
  800ae5:	0f 48 f8             	cmovs  %eax,%edi
  800ae8:	c1 ff 0c             	sar    $0xc,%edi
	new_nblocks = (newsize + BLKSIZE - 1) / BLKSIZE;
  800aeb:	8d 82 fe 1f 00 00    	lea    0x1ffe(%edx),%eax
  800af1:	81 c2 ff 0f 00 00    	add    $0xfff,%edx
  800af7:	0f 48 d0             	cmovs  %eax,%edx
  800afa:	c1 fa 0c             	sar    $0xc,%edx
  800afd:	89 55 d4             	mov    %edx,-0x2c(%ebp)
	for (bno = new_nblocks; bno < old_nblocks; bno++)
  800b00:	39 d7                	cmp    %edx,%edi
  800b02:	76 4c                	jbe    800b50 <file_truncate_blocks+0x88>
  800b04:	89 d3                	mov    %edx,%ebx
file_free_block(struct File *f, uint32_t filebno)
{
	int r;
	uint32_t *ptr;

	if ((r = file_block_walk(f, filebno, &ptr, 0)) < 0)
  800b06:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800b0d:	8d 4d e4             	lea    -0x1c(%ebp),%ecx
  800b10:	89 da                	mov    %ebx,%edx
  800b12:	89 f0                	mov    %esi,%eax
  800b14:	e8 a5 fe ff ff       	call   8009be <file_block_walk>
  800b19:	85 c0                	test   %eax,%eax
  800b1b:	78 1c                	js     800b39 <file_truncate_blocks+0x71>
		return r;
	if (*ptr) {
  800b1d:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800b20:	8b 00                	mov    (%eax),%eax
  800b22:	85 c0                	test   %eax,%eax
  800b24:	74 23                	je     800b49 <file_truncate_blocks+0x81>
		free_block(*ptr);
  800b26:	89 04 24             	mov    %eax,(%esp)
  800b29:	e8 16 fd ff ff       	call   800844 <free_block>
		*ptr = 0;
  800b2e:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800b31:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
  800b37:	eb 10                	jmp    800b49 <file_truncate_blocks+0x81>

	old_nblocks = (f->f_size + BLKSIZE - 1) / BLKSIZE;
	new_nblocks = (newsize + BLKSIZE - 1) / BLKSIZE;
	for (bno = new_nblocks; bno < old_nblocks; bno++)
		if ((r = file_free_block(f, bno)) < 0)
			cprintf("warning: file_free_block: %e", r);
  800b39:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b3d:	c7 04 24 1a 49 80 00 	movl   $0x80491a,(%esp)
  800b44:	e8 fc 13 00 00       	call   801f45 <cprintf>
	int r;
	uint32_t bno, old_nblocks, new_nblocks;

	old_nblocks = (f->f_size + BLKSIZE - 1) / BLKSIZE;
	new_nblocks = (newsize + BLKSIZE - 1) / BLKSIZE;
	for (bno = new_nblocks; bno < old_nblocks; bno++)
  800b49:	83 c3 01             	add    $0x1,%ebx
  800b4c:	39 df                	cmp    %ebx,%edi
  800b4e:	77 b6                	ja     800b06 <file_truncate_blocks+0x3e>
		if ((r = file_free_block(f, bno)) < 0)
			cprintf("warning: file_free_block: %e", r);

	if (new_nblocks <= NDIRECT && f->f_indirect) {
  800b50:	83 7d d4 0a          	cmpl   $0xa,-0x2c(%ebp)
  800b54:	77 1c                	ja     800b72 <file_truncate_blocks+0xaa>
  800b56:	8b 86 b0 00 00 00    	mov    0xb0(%esi),%eax
  800b5c:	85 c0                	test   %eax,%eax
  800b5e:	74 12                	je     800b72 <file_truncate_blocks+0xaa>
		free_block(f->f_indirect);
  800b60:	89 04 24             	mov    %eax,(%esp)
  800b63:	e8 dc fc ff ff       	call   800844 <free_block>
		f->f_indirect = 0;
  800b68:	c7 86 b0 00 00 00 00 	movl   $0x0,0xb0(%esi)
  800b6f:	00 00 00 
	}
}
  800b72:	83 c4 3c             	add    $0x3c,%esp
  800b75:	5b                   	pop    %ebx
  800b76:	5e                   	pop    %esi
  800b77:	5f                   	pop    %edi
  800b78:	5d                   	pop    %ebp
  800b79:	c3                   	ret    

00800b7a <file_set_size>:

// Set the size of file f, truncating or extending as necessary.
int
file_set_size(struct File *f, off_t newsize)
{
  800b7a:	55                   	push   %ebp
  800b7b:	89 e5                	mov    %esp,%ebp
  800b7d:	83 ec 18             	sub    $0x18,%esp
  800b80:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800b83:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800b86:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800b89:	8b 75 0c             	mov    0xc(%ebp),%esi
	if (f->f_size > newsize)
  800b8c:	39 b3 80 00 00 00    	cmp    %esi,0x80(%ebx)
  800b92:	7e 09                	jle    800b9d <file_set_size+0x23>
		file_truncate_blocks(f, newsize);
  800b94:	89 f2                	mov    %esi,%edx
  800b96:	89 d8                	mov    %ebx,%eax
  800b98:	e8 2b ff ff ff       	call   800ac8 <file_truncate_blocks>
	f->f_size = newsize;
  800b9d:	89 b3 80 00 00 00    	mov    %esi,0x80(%ebx)
	flush_block(f);
  800ba3:	89 1c 24             	mov    %ebx,(%esp)
  800ba6:	e8 b2 f8 ff ff       	call   80045d <flush_block>
	return 0;
}
  800bab:	b8 00 00 00 00       	mov    $0x0,%eax
  800bb0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800bb3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800bb6:	89 ec                	mov    %ebp,%esp
  800bb8:	5d                   	pop    %ebp
  800bb9:	c3                   	ret    

00800bba <file_flush>:
// Loop over all the blocks in file.
// Translate the file block number into a disk block number
// and then check whether that disk block is dirty.  If so, write it out.
void
file_flush(struct File *f)
{
  800bba:	55                   	push   %ebp
  800bbb:	89 e5                	mov    %esp,%ebp
  800bbd:	57                   	push   %edi
  800bbe:	56                   	push   %esi
  800bbf:	53                   	push   %ebx
  800bc0:	83 ec 2c             	sub    $0x2c,%esp
  800bc3:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int i;
	uint32_t *pdiskbno;

	for (i = 0; i < (f->f_size + BLKSIZE - 1) / BLKSIZE; i++) {
  800bc6:	8b 83 80 00 00 00    	mov    0x80(%ebx),%eax
  800bcc:	05 ff 0f 00 00       	add    $0xfff,%eax
  800bd1:	3d ff 0f 00 00       	cmp    $0xfff,%eax
  800bd6:	7e 59                	jle    800c31 <file_flush+0x77>
  800bd8:	be 00 00 00 00       	mov    $0x0,%esi
		if (file_block_walk(f, i, &pdiskbno, 0) < 0 ||
  800bdd:	8d 7d e4             	lea    -0x1c(%ebp),%edi
  800be0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800be7:	89 f9                	mov    %edi,%ecx
  800be9:	89 f2                	mov    %esi,%edx
  800beb:	89 d8                	mov    %ebx,%eax
  800bed:	e8 cc fd ff ff       	call   8009be <file_block_walk>
  800bf2:	85 c0                	test   %eax,%eax
  800bf4:	78 1d                	js     800c13 <file_flush+0x59>
		    pdiskbno == NULL || *pdiskbno == 0)
  800bf6:	8b 45 e4             	mov    -0x1c(%ebp),%eax
{
	int i;
	uint32_t *pdiskbno;

	for (i = 0; i < (f->f_size + BLKSIZE - 1) / BLKSIZE; i++) {
		if (file_block_walk(f, i, &pdiskbno, 0) < 0 ||
  800bf9:	85 c0                	test   %eax,%eax
  800bfb:	74 16                	je     800c13 <file_flush+0x59>
		    pdiskbno == NULL || *pdiskbno == 0)
  800bfd:	8b 00                	mov    (%eax),%eax
{
	int i;
	uint32_t *pdiskbno;

	for (i = 0; i < (f->f_size + BLKSIZE - 1) / BLKSIZE; i++) {
		if (file_block_walk(f, i, &pdiskbno, 0) < 0 ||
  800bff:	85 c0                	test   %eax,%eax
  800c01:	74 10                	je     800c13 <file_flush+0x59>
		    pdiskbno == NULL || *pdiskbno == 0)
			continue;
		flush_block(diskaddr(*pdiskbno));
  800c03:	89 04 24             	mov    %eax,(%esp)
  800c06:	e8 c8 f6 ff ff       	call   8002d3 <diskaddr>
  800c0b:	89 04 24             	mov    %eax,(%esp)
  800c0e:	e8 4a f8 ff ff       	call   80045d <flush_block>
file_flush(struct File *f)
{
	int i;
	uint32_t *pdiskbno;

	for (i = 0; i < (f->f_size + BLKSIZE - 1) / BLKSIZE; i++) {
  800c13:	83 c6 01             	add    $0x1,%esi
  800c16:	8b 83 80 00 00 00    	mov    0x80(%ebx),%eax
  800c1c:	8d 90 fe 1f 00 00    	lea    0x1ffe(%eax),%edx
  800c22:	05 ff 0f 00 00       	add    $0xfff,%eax
  800c27:	0f 48 c2             	cmovs  %edx,%eax
  800c2a:	c1 f8 0c             	sar    $0xc,%eax
  800c2d:	39 f0                	cmp    %esi,%eax
  800c2f:	7f af                	jg     800be0 <file_flush+0x26>
		if (file_block_walk(f, i, &pdiskbno, 0) < 0 ||
		    pdiskbno == NULL || *pdiskbno == 0)
			continue;
		flush_block(diskaddr(*pdiskbno));
	}
	flush_block(f);
  800c31:	89 1c 24             	mov    %ebx,(%esp)
  800c34:	e8 24 f8 ff ff       	call   80045d <flush_block>
	if (f->f_indirect)
  800c39:	8b 83 b0 00 00 00    	mov    0xb0(%ebx),%eax
  800c3f:	85 c0                	test   %eax,%eax
  800c41:	74 10                	je     800c53 <file_flush+0x99>
		flush_block(diskaddr(f->f_indirect));
  800c43:	89 04 24             	mov    %eax,(%esp)
  800c46:	e8 88 f6 ff ff       	call   8002d3 <diskaddr>
  800c4b:	89 04 24             	mov    %eax,(%esp)
  800c4e:	e8 0a f8 ff ff       	call   80045d <flush_block>
}
  800c53:	83 c4 2c             	add    $0x2c,%esp
  800c56:	5b                   	pop    %ebx
  800c57:	5e                   	pop    %esi
  800c58:	5f                   	pop    %edi
  800c59:	5d                   	pop    %ebp
  800c5a:	c3                   	ret    

00800c5b <file_get_block>:
//	-E_INVAL if filebno is out of range.
//
// Hint: Use file_block_walk and alloc_block.
int
file_get_block(struct File *f, uint32_t filebno, char **blk)
{
  800c5b:	55                   	push   %ebp
  800c5c:	89 e5                	mov    %esp,%ebp
  800c5e:	83 ec 48             	sub    $0x48,%esp
  800c61:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800c64:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800c67:	89 7d fc             	mov    %edi,-0x4(%ebp)
  800c6a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800c6d:	8b 7d 10             	mov    0x10(%ebp),%edi
    uint32_t *d_block   = NULL;
    int r   = 0;

    if (!f || !blk)
  800c70:	85 db                	test   %ebx,%ebx
  800c72:	74 04                	je     800c78 <file_get_block+0x1d>
  800c74:	85 ff                	test   %edi,%edi
  800c76:	75 0a                	jne    800c82 <file_get_block+0x27>
  800c78:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800c7d:	e9 d5 00 00 00       	jmp    800d57 <file_get_block+0xfc>
//
// Hint: Use file_block_walk and alloc_block.
int
file_get_block(struct File *f, uint32_t filebno, char **blk)
{
    uint32_t *d_block   = NULL;
  800c82:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
    int r   = 0;

    if (!f || !blk)
        return -E_INVAL;

    if ((r=file_block_walk(f, filebno, &d_block, 1)) < 0)
  800c89:	8d 4d e4             	lea    -0x1c(%ebp),%ecx
  800c8c:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  800c93:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c96:	89 d8                	mov    %ebx,%eax
  800c98:	e8 21 fd ff ff       	call   8009be <file_block_walk>
  800c9d:	85 c0                	test   %eax,%eax
  800c9f:	0f 88 b2 00 00 00    	js     800d57 <file_get_block+0xfc>
        return r;
     
    if (*d_block == 0) {
  800ca5:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  800ca8:	83 3e 00             	cmpl   $0x0,(%esi)
  800cab:	0f 85 92 00 00 00    	jne    800d43 <file_get_block+0xe8>
        *d_block    = alloc_block();
  800cb1:	e8 fc fa ff ff       	call   8007b2 <alloc_block>
  800cb6:	89 06                	mov    %eax,(%esi)
        if (*d_block < 0) {
            *d_block    = 0;
            return -E_NO_DISK;
        }
        if (filebno < NDIRECT) {
  800cb8:	83 7d 0c 09          	cmpl   $0x9,0xc(%ebp)
  800cbc:	77 3e                	ja     800cfc <file_get_block+0xa1>
            if ((r=sys_page_map(env->env_id, (void *)f, env->env_id, (void *)f, PGOFF(vpt[VPN(f)])|PTE_D))<0)
  800cbe:	89 d8                	mov    %ebx,%eax
  800cc0:	c1 e8 0c             	shr    $0xc,%eax
  800cc3:	8b 0c 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%ecx
  800cca:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  800ccf:	8b 50 4c             	mov    0x4c(%eax),%edx
  800cd2:	8b 40 4c             	mov    0x4c(%eax),%eax
  800cd5:	81 e1 bf 0f 00 00    	and    $0xfbf,%ecx
  800cdb:	83 c9 40             	or     $0x40,%ecx
  800cde:	89 4c 24 10          	mov    %ecx,0x10(%esp)
  800ce2:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800ce6:	89 54 24 08          	mov    %edx,0x8(%esp)
  800cea:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800cee:	89 04 24             	mov    %eax,(%esp)
  800cf1:	e8 22 20 00 00       	call   802d18 <sys_page_map>
  800cf6:	85 c0                	test   %eax,%eax
  800cf8:	79 49                	jns    800d43 <file_get_block+0xe8>
  800cfa:	eb 5b                	jmp    800d57 <file_get_block+0xfc>
                return r;
        } else {
            void *d_addr    = diskaddr(f->f_indirect);
  800cfc:	8b 83 b0 00 00 00    	mov    0xb0(%ebx),%eax
  800d02:	89 04 24             	mov    %eax,(%esp)
  800d05:	e8 c9 f5 ff ff       	call   8002d3 <diskaddr>
            if ((r=sys_page_map(0, d_addr, 0, d_addr, PGOFF(vpt[VPN(d_addr)])|PTE_D))<0)
  800d0a:	89 c2                	mov    %eax,%edx
  800d0c:	c1 ea 0c             	shr    $0xc,%edx
  800d0f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  800d16:	81 e2 bf 0f 00 00    	and    $0xfbf,%edx
  800d1c:	83 ca 40             	or     $0x40,%edx
  800d1f:	89 54 24 10          	mov    %edx,0x10(%esp)
  800d23:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800d27:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  800d2e:	00 
  800d2f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d33:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800d3a:	e8 d9 1f 00 00       	call   802d18 <sys_page_map>
  800d3f:	85 c0                	test   %eax,%eax
  800d41:	78 14                	js     800d57 <file_get_block+0xfc>
                return r;
        }
    }
    *blk    = (char *)diskaddr(*d_block);
  800d43:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800d46:	8b 00                	mov    (%eax),%eax
  800d48:	89 04 24             	mov    %eax,(%esp)
  800d4b:	e8 83 f5 ff ff       	call   8002d3 <diskaddr>
  800d50:	89 07                	mov    %eax,(%edi)
  800d52:	b8 00 00 00 00       	mov    $0x0,%eax
    return 0;
}
  800d57:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800d5a:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800d5d:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800d60:	89 ec                	mov    %ebp,%esp
  800d62:	5d                   	pop    %ebp
  800d63:	c3                   	ret    

00800d64 <walk_path>:
// If we cannot find the file but find the directory
// it should be in, set *pdir and copy the final path
// element into lastelem.
static int
walk_path(const char *path, struct File **pdir, struct File **pf, char *lastelem)
{
  800d64:	55                   	push   %ebp
  800d65:	89 e5                	mov    %esp,%ebp
  800d67:	57                   	push   %edi
  800d68:	56                   	push   %esi
  800d69:	53                   	push   %ebx
  800d6a:	81 ec cc 00 00 00    	sub    $0xcc,%esp
  800d70:	89 95 40 ff ff ff    	mov    %edx,-0xc0(%ebp)
  800d76:	89 8d 3c ff ff ff    	mov    %ecx,-0xc4(%ebp)
	struct File *dir, *f;
	int r;

	// if (*path != '/')
	//	return -E_BAD_PATH;
	path = skip_slash(path);
  800d7c:	e8 dd f9 ff ff       	call   80075e <skip_slash>
  800d81:	89 85 48 ff ff ff    	mov    %eax,-0xb8(%ebp)
	f = &super->s_root;
  800d87:	a1 dc d0 80 00       	mov    0x80d0dc,%eax
	dir = 0;
	name[0] = 0;
  800d8c:	c6 85 68 ff ff ff 00 	movb   $0x0,-0x98(%ebp)

	if (pdir)
  800d93:	83 bd 40 ff ff ff 00 	cmpl   $0x0,-0xc0(%ebp)
  800d9a:	74 0c                	je     800da8 <walk_path+0x44>
		*pdir = 0;
  800d9c:	8b 95 40 ff ff ff    	mov    -0xc0(%ebp),%edx
  800da2:	c7 02 00 00 00 00    	movl   $0x0,(%edx)
	int r;

	// if (*path != '/')
	//	return -E_BAD_PATH;
	path = skip_slash(path);
	f = &super->s_root;
  800da8:	83 c0 08             	add    $0x8,%eax
  800dab:	89 85 4c ff ff ff    	mov    %eax,-0xb4(%ebp)
	dir = 0;
	name[0] = 0;

	if (pdir)
		*pdir = 0;
	*pf = 0;
  800db1:	8b 8d 3c ff ff ff    	mov    -0xc4(%ebp),%ecx
  800db7:	c7 01 00 00 00 00    	movl   $0x0,(%ecx)
  800dbd:	ba 00 00 00 00       	mov    $0x0,%edx
	while (*path != '\0') {
  800dc2:	e9 a0 01 00 00       	jmp    800f67 <walk_path+0x203>
		dir = f;
		p = path;
		while (*path != '/' && *path != '\0')
			path++;
  800dc7:	83 c6 01             	add    $0x1,%esi
		*pdir = 0;
	*pf = 0;
	while (*path != '\0') {
		dir = f;
		p = path;
		while (*path != '/' && *path != '\0')
  800dca:	0f b6 06             	movzbl (%esi),%eax
  800dcd:	3c 2f                	cmp    $0x2f,%al
  800dcf:	74 04                	je     800dd5 <walk_path+0x71>
  800dd1:	84 c0                	test   %al,%al
  800dd3:	75 f2                	jne    800dc7 <walk_path+0x63>
			path++;
		if (path - p >= MAXNAMELEN)
  800dd5:	89 f3                	mov    %esi,%ebx
  800dd7:	2b 9d 48 ff ff ff    	sub    -0xb8(%ebp),%ebx
  800ddd:	83 fb 7f             	cmp    $0x7f,%ebx
  800de0:	7e 0a                	jle    800dec <walk_path+0x88>
  800de2:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  800de7:	e9 c2 01 00 00       	jmp    800fae <walk_path+0x24a>
			return -E_BAD_PATH;
		memmove(name, p, path - p);
  800dec:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800df0:	8b 85 48 ff ff ff    	mov    -0xb8(%ebp),%eax
  800df6:	89 44 24 04          	mov    %eax,0x4(%esp)
  800dfa:	8d 95 68 ff ff ff    	lea    -0x98(%ebp),%edx
  800e00:	89 14 24             	mov    %edx,(%esp)
  800e03:	e8 cd 19 00 00       	call   8027d5 <memmove>
		name[path - p] = '\0';
  800e08:	c6 84 1d 68 ff ff ff 	movb   $0x0,-0x98(%ebp,%ebx,1)
  800e0f:	00 
		path = skip_slash(path);
  800e10:	89 f0                	mov    %esi,%eax
  800e12:	e8 47 f9 ff ff       	call   80075e <skip_slash>
  800e17:	89 85 48 ff ff ff    	mov    %eax,-0xb8(%ebp)

		if (dir->f_type != FTYPE_DIR)
  800e1d:	8b 8d 4c ff ff ff    	mov    -0xb4(%ebp),%ecx
  800e23:	83 b9 84 00 00 00 01 	cmpl   $0x1,0x84(%ecx)
  800e2a:	0f 85 79 01 00 00    	jne    800fa9 <walk_path+0x245>
	struct File *f;

	// Search dir for name.
	// We maintain the invariant that the size of a directory-file
	// is always a multiple of the file system's block size.
	assert((dir->f_size % BLKSIZE) == 0);
  800e30:	8b 81 80 00 00 00    	mov    0x80(%ecx),%eax
  800e36:	a9 ff 0f 00 00       	test   $0xfff,%eax
  800e3b:	74 24                	je     800e61 <walk_path+0xfd>
  800e3d:	c7 44 24 0c 37 49 80 	movl   $0x804937,0xc(%esp)
  800e44:	00 
  800e45:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  800e4c:	00 
  800e4d:	c7 44 24 04 dd 00 00 	movl   $0xdd,0x4(%esp)
  800e54:	00 
  800e55:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  800e5c:	e8 1f 10 00 00       	call   801e80 <_panic>
	nblock = dir->f_size / BLKSIZE;
  800e61:	8d 90 ff 0f 00 00    	lea    0xfff(%eax),%edx
  800e67:	85 c0                	test   %eax,%eax
  800e69:	0f 48 c2             	cmovs  %edx,%eax
  800e6c:	c1 f8 0c             	sar    $0xc,%eax
  800e6f:	89 85 44 ff ff ff    	mov    %eax,-0xbc(%ebp)
	for (i = 0; i < nblock; i++) {
  800e75:	85 c0                	test   %eax,%eax
  800e77:	0f 84 8a 00 00 00    	je     800f07 <walk_path+0x1a3>
  800e7d:	c7 85 50 ff ff ff 00 	movl   $0x0,-0xb0(%ebp)
  800e84:	00 00 00 
		if ((r = file_get_block(dir, i, &blk)) < 0)
			return r;
		f = (struct File*) blk;
		for (j = 0; j < BLKFILES; j++)
			if (strcmp(f[j].f_name, name) == 0) {
  800e87:	8d b5 68 ff ff ff    	lea    -0x98(%ebp),%esi
	// We maintain the invariant that the size of a directory-file
	// is always a multiple of the file system's block size.
	assert((dir->f_size % BLKSIZE) == 0);
	nblock = dir->f_size / BLKSIZE;
	for (i = 0; i < nblock; i++) {
		if ((r = file_get_block(dir, i, &blk)) < 0)
  800e8d:	8d 85 64 ff ff ff    	lea    -0x9c(%ebp),%eax
  800e93:	89 44 24 08          	mov    %eax,0x8(%esp)
  800e97:	8b 95 50 ff ff ff    	mov    -0xb0(%ebp),%edx
  800e9d:	89 54 24 04          	mov    %edx,0x4(%esp)
  800ea1:	8b 8d 4c ff ff ff    	mov    -0xb4(%ebp),%ecx
  800ea7:	89 0c 24             	mov    %ecx,(%esp)
  800eaa:	e8 ac fd ff ff       	call   800c5b <file_get_block>
  800eaf:	85 c0                	test   %eax,%eax
  800eb1:	78 4b                	js     800efe <walk_path+0x19a>
  800eb3:	8b 9d 64 ff ff ff    	mov    -0x9c(%ebp),%ebx
// and set *pdir to the directory the file is in.
// If we cannot find the file but find the directory
// it should be in, set *pdir and copy the final path
// element into lastelem.
static int
walk_path(const char *path, struct File **pdir, struct File **pf, char *lastelem)
  800eb9:	8d 83 00 10 00 00    	lea    0x1000(%ebx),%eax
  800ebf:	89 85 54 ff ff ff    	mov    %eax,-0xac(%ebp)
	for (i = 0; i < nblock; i++) {
		if ((r = file_get_block(dir, i, &blk)) < 0)
			return r;
		f = (struct File*) blk;
		for (j = 0; j < BLKFILES; j++)
			if (strcmp(f[j].f_name, name) == 0) {
  800ec5:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ec9:	89 1c 24             	mov    %ebx,(%esp)
  800ecc:	e8 d8 17 00 00       	call   8026a9 <strcmp>
  800ed1:	85 c0                	test   %eax,%eax
  800ed3:	0f 84 82 00 00 00    	je     800f5b <walk_path+0x1f7>
  800ed9:	81 c3 00 01 00 00    	add    $0x100,%ebx
	nblock = dir->f_size / BLKSIZE;
	for (i = 0; i < nblock; i++) {
		if ((r = file_get_block(dir, i, &blk)) < 0)
			return r;
		f = (struct File*) blk;
		for (j = 0; j < BLKFILES; j++)
  800edf:	3b 9d 54 ff ff ff    	cmp    -0xac(%ebp),%ebx
  800ee5:	75 de                	jne    800ec5 <walk_path+0x161>
	// Search dir for name.
	// We maintain the invariant that the size of a directory-file
	// is always a multiple of the file system's block size.
	assert((dir->f_size % BLKSIZE) == 0);
	nblock = dir->f_size / BLKSIZE;
	for (i = 0; i < nblock; i++) {
  800ee7:	83 85 50 ff ff ff 01 	addl   $0x1,-0xb0(%ebp)
  800eee:	8b 95 50 ff ff ff    	mov    -0xb0(%ebp),%edx
  800ef4:	39 95 44 ff ff ff    	cmp    %edx,-0xbc(%ebp)
  800efa:	77 91                	ja     800e8d <walk_path+0x129>
  800efc:	eb 09                	jmp    800f07 <walk_path+0x1a3>

		if (dir->f_type != FTYPE_DIR)
			return -E_NOT_FOUND;

		if ((r = dir_lookup(dir, name, &f)) < 0) {
			if (r == -E_NOT_FOUND && *path == '\0') {
  800efe:	83 f8 f5             	cmp    $0xfffffff5,%eax
  800f01:	0f 85 a7 00 00 00    	jne    800fae <walk_path+0x24a>
  800f07:	8b 8d 48 ff ff ff    	mov    -0xb8(%ebp),%ecx
  800f0d:	80 39 00             	cmpb   $0x0,(%ecx)
  800f10:	0f 85 93 00 00 00    	jne    800fa9 <walk_path+0x245>
				if (pdir)
  800f16:	83 bd 40 ff ff ff 00 	cmpl   $0x0,-0xc0(%ebp)
  800f1d:	74 0e                	je     800f2d <walk_path+0x1c9>
					*pdir = dir;
  800f1f:	8b 95 4c ff ff ff    	mov    -0xb4(%ebp),%edx
  800f25:	8b 85 40 ff ff ff    	mov    -0xc0(%ebp),%eax
  800f2b:	89 10                	mov    %edx,(%eax)
				if (lastelem)
  800f2d:	83 7d 08 00          	cmpl   $0x0,0x8(%ebp)
  800f31:	74 15                	je     800f48 <walk_path+0x1e4>
					strcpy(lastelem, name);
  800f33:	8d 85 68 ff ff ff    	lea    -0x98(%ebp),%eax
  800f39:	89 44 24 04          	mov    %eax,0x4(%esp)
  800f3d:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800f40:	89 0c 24             	mov    %ecx,(%esp)
  800f43:	e8 d2 16 00 00       	call   80261a <strcpy>
				*pf = 0;
  800f48:	8b 85 3c ff ff ff    	mov    -0xc4(%ebp),%eax
  800f4e:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
  800f54:	b8 f5 ff ff ff       	mov    $0xfffffff5,%eax
  800f59:	eb 53                	jmp    800fae <walk_path+0x24a>
  800f5b:	8b 95 4c ff ff ff    	mov    -0xb4(%ebp),%edx
  800f61:	89 9d 4c ff ff ff    	mov    %ebx,-0xb4(%ebp)
	name[0] = 0;

	if (pdir)
		*pdir = 0;
	*pf = 0;
	while (*path != '\0') {
  800f67:	8b 8d 48 ff ff ff    	mov    -0xb8(%ebp),%ecx
  800f6d:	0f b6 01             	movzbl (%ecx),%eax
  800f70:	84 c0                	test   %al,%al
  800f72:	74 0f                	je     800f83 <walk_path+0x21f>
  800f74:	89 ce                	mov    %ecx,%esi
		dir = f;
		p = path;
		while (*path != '/' && *path != '\0')
  800f76:	3c 2f                	cmp    $0x2f,%al
  800f78:	0f 85 49 fe ff ff    	jne    800dc7 <walk_path+0x63>
  800f7e:	e9 52 fe ff ff       	jmp    800dd5 <walk_path+0x71>
			}
			return r;
		}
	}

	if (pdir)
  800f83:	83 bd 40 ff ff ff 00 	cmpl   $0x0,-0xc0(%ebp)
  800f8a:	74 08                	je     800f94 <walk_path+0x230>
		*pdir = dir;
  800f8c:	8b 85 40 ff ff ff    	mov    -0xc0(%ebp),%eax
  800f92:	89 10                	mov    %edx,(%eax)
	*pf = f;
  800f94:	8b 8d 4c ff ff ff    	mov    -0xb4(%ebp),%ecx
  800f9a:	8b 95 3c ff ff ff    	mov    -0xc4(%ebp),%edx
  800fa0:	89 0a                	mov    %ecx,(%edx)
  800fa2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  800fa7:	eb 05                	jmp    800fae <walk_path+0x24a>
  800fa9:	b8 f5 ff ff ff       	mov    $0xfffffff5,%eax
}
  800fae:	81 c4 cc 00 00 00    	add    $0xcc,%esp
  800fb4:	5b                   	pop    %ebx
  800fb5:	5e                   	pop    %esi
  800fb6:	5f                   	pop    %edi
  800fb7:	5d                   	pop    %ebp
  800fb8:	c3                   	ret    

00800fb9 <file_remove>:
}

// Remove a file by truncating it and then zeroing the name.
int
file_remove(const char *path)
{
  800fb9:	55                   	push   %ebp
  800fba:	89 e5                	mov    %esp,%ebp
  800fbc:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct File *f;

	if ((r = walk_path(path, 0, &f, 0)) < 0)
  800fbf:	8d 4d f4             	lea    -0xc(%ebp),%ecx
  800fc2:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800fc9:	ba 00 00 00 00       	mov    $0x0,%edx
  800fce:	8b 45 08             	mov    0x8(%ebp),%eax
  800fd1:	e8 8e fd ff ff       	call   800d64 <walk_path>
  800fd6:	85 c0                	test   %eax,%eax
  800fd8:	78 30                	js     80100a <file_remove+0x51>
		return r;

	file_truncate_blocks(f, 0);
  800fda:	ba 00 00 00 00       	mov    $0x0,%edx
  800fdf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800fe2:	e8 e1 fa ff ff       	call   800ac8 <file_truncate_blocks>
	f->f_name[0] = '\0';
  800fe7:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800fea:	c6 00 00             	movb   $0x0,(%eax)
	f->f_size = 0;
  800fed:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800ff0:	c7 80 80 00 00 00 00 	movl   $0x0,0x80(%eax)
  800ff7:	00 00 00 
	flush_block(f);
  800ffa:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800ffd:	89 04 24             	mov    %eax,(%esp)
  801000:	e8 58 f4 ff ff       	call   80045d <flush_block>
  801005:	b8 00 00 00 00       	mov    $0x0,%eax

	return 0;
}
  80100a:	c9                   	leave  
  80100b:	c3                   	ret    

0080100c <file_open>:

// Open "path".  On success set *pf to point at the file and return 0.
// On error return < 0.
int
file_open(const char *path, struct File **pf)
{
  80100c:	55                   	push   %ebp
  80100d:	89 e5                	mov    %esp,%ebp
  80100f:	83 ec 18             	sub    $0x18,%esp
	return walk_path(path, 0, pf, 0);
  801012:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801019:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80101c:	ba 00 00 00 00       	mov    $0x0,%edx
  801021:	8b 45 08             	mov    0x8(%ebp),%eax
  801024:	e8 3b fd ff ff       	call   800d64 <walk_path>
}
  801029:	c9                   	leave  
  80102a:	c3                   	ret    

0080102b <file_write>:
// offset.  This is meant to mimic the standard pwrite function.
// Extends the file if necessary.
// Returns the number of bytes written, < 0 on error.
int
file_write(struct File *f, const void *buf, size_t count, off_t offset)
{
  80102b:	55                   	push   %ebp
  80102c:	89 e5                	mov    %esp,%ebp
  80102e:	57                   	push   %edi
  80102f:	56                   	push   %esi
  801030:	53                   	push   %ebx
  801031:	83 ec 3c             	sub    $0x3c,%esp
  801034:	8b 7d 0c             	mov    0xc(%ebp),%edi
  801037:	8b 5d 14             	mov    0x14(%ebp),%ebx
	int r, bn;
	off_t pos;
	char *blk;

	// Extend file if necessary
	if (offset + count > f->f_size)
  80103a:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  80103d:	8b 45 10             	mov    0x10(%ebp),%eax
  801040:	01 d8                	add    %ebx,%eax
  801042:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  801045:	8b 55 08             	mov    0x8(%ebp),%edx
  801048:	3b 82 80 00 00 00    	cmp    0x80(%edx),%eax
  80104e:	77 0d                	ja     80105d <file_write+0x32>
		if ((r = file_set_size(f, offset + count)) < 0)
			return r;
	for (pos = offset; pos < offset + count; ) {
  801050:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801053:	39 45 d0             	cmp    %eax,-0x30(%ebp)
  801056:	72 1d                	jb     801075 <file_write+0x4a>
  801058:	e9 85 00 00 00       	jmp    8010e2 <file_write+0xb7>
	off_t pos;
	char *blk;

	// Extend file if necessary
	if (offset + count > f->f_size)
		if ((r = file_set_size(f, offset + count)) < 0)
  80105d:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  801060:	89 54 24 04          	mov    %edx,0x4(%esp)
  801064:	8b 45 08             	mov    0x8(%ebp),%eax
  801067:	89 04 24             	mov    %eax,(%esp)
  80106a:	e8 0b fb ff ff       	call   800b7a <file_set_size>
  80106f:	85 c0                	test   %eax,%eax
  801071:	79 dd                	jns    801050 <file_write+0x25>
  801073:	eb 70                	jmp    8010e5 <file_write+0xba>
			return r;
	for (pos = offset; pos < offset + count; ) {
		if ((r = file_get_block(f, pos / BLKSIZE, &blk)) < 0)
  801075:	8d 55 e4             	lea    -0x1c(%ebp),%edx
  801078:	89 54 24 08          	mov    %edx,0x8(%esp)
  80107c:	8d 83 ff 0f 00 00    	lea    0xfff(%ebx),%eax
  801082:	85 db                	test   %ebx,%ebx
  801084:	0f 49 c3             	cmovns %ebx,%eax
  801087:	c1 f8 0c             	sar    $0xc,%eax
  80108a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80108e:	8b 45 08             	mov    0x8(%ebp),%eax
  801091:	89 04 24             	mov    %eax,(%esp)
  801094:	e8 c2 fb ff ff       	call   800c5b <file_get_block>
  801099:	85 c0                	test   %eax,%eax
  80109b:	78 48                	js     8010e5 <file_write+0xba>
			return r;
		bn = MIN(BLKSIZE - pos % BLKSIZE, offset + count - pos);
  80109d:	89 da                	mov    %ebx,%edx
  80109f:	c1 fa 1f             	sar    $0x1f,%edx
  8010a2:	c1 ea 14             	shr    $0x14,%edx
  8010a5:	8d 04 13             	lea    (%ebx,%edx,1),%eax
  8010a8:	25 ff 0f 00 00       	and    $0xfff,%eax
  8010ad:	29 d0                	sub    %edx,%eax
  8010af:	be 00 10 00 00       	mov    $0x1000,%esi
  8010b4:	29 c6                	sub    %eax,%esi
  8010b6:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  8010b9:	2b 55 d0             	sub    -0x30(%ebp),%edx
  8010bc:	39 d6                	cmp    %edx,%esi
  8010be:	0f 47 f2             	cmova  %edx,%esi
		memmove(blk + pos % BLKSIZE, buf, bn);
  8010c1:	89 74 24 08          	mov    %esi,0x8(%esp)
  8010c5:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8010c9:	03 45 e4             	add    -0x1c(%ebp),%eax
  8010cc:	89 04 24             	mov    %eax,(%esp)
  8010cf:	e8 01 17 00 00       	call   8027d5 <memmove>
		pos += bn;
  8010d4:	01 f3                	add    %esi,%ebx

	// Extend file if necessary
	if (offset + count > f->f_size)
		if ((r = file_set_size(f, offset + count)) < 0)
			return r;
	for (pos = offset; pos < offset + count; ) {
  8010d6:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  8010d9:	39 5d d4             	cmp    %ebx,-0x2c(%ebp)
  8010dc:	76 04                	jbe    8010e2 <file_write+0xb7>
		if ((r = file_get_block(f, pos / BLKSIZE, &blk)) < 0)
			return r;
		bn = MIN(BLKSIZE - pos % BLKSIZE, offset + count - pos);
		memmove(blk + pos % BLKSIZE, buf, bn);
		pos += bn;
		buf += bn;
  8010de:	01 f7                	add    %esi,%edi
  8010e0:	eb 93                	jmp    801075 <file_write+0x4a>
	}

	return count;
  8010e2:	8b 45 10             	mov    0x10(%ebp),%eax
}
  8010e5:	83 c4 3c             	add    $0x3c,%esp
  8010e8:	5b                   	pop    %ebx
  8010e9:	5e                   	pop    %esi
  8010ea:	5f                   	pop    %edi
  8010eb:	5d                   	pop    %ebp
  8010ec:	c3                   	ret    

008010ed <file_read>:
// Read count bytes from f into buf, starting from seek position
// offset.  This meant to mimic the standard pread function.
// Returns the number of bytes read, < 0 on error.
ssize_t
file_read(struct File *f, void *buf, size_t count, off_t offset)
{
  8010ed:	55                   	push   %ebp
  8010ee:	89 e5                	mov    %esp,%ebp
  8010f0:	57                   	push   %edi
  8010f1:	56                   	push   %esi
  8010f2:	53                   	push   %ebx
  8010f3:	83 ec 3c             	sub    $0x3c,%esp
  8010f6:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8010f9:	8b 55 10             	mov    0x10(%ebp),%edx
  8010fc:	8b 5d 14             	mov    0x14(%ebp),%ebx
	int r, bn;
	off_t pos;
	char *blk;

	if (offset >= f->f_size)
  8010ff:	8b 45 08             	mov    0x8(%ebp),%eax
  801102:	8b 88 80 00 00 00    	mov    0x80(%eax),%ecx
  801108:	b8 00 00 00 00       	mov    $0x0,%eax
  80110d:	39 d9                	cmp    %ebx,%ecx
  80110f:	0f 8e 88 00 00 00    	jle    80119d <file_read+0xb0>
		return 0;

	count = MIN(count, f->f_size - offset);
  801115:	29 d9                	sub    %ebx,%ecx
  801117:	39 d1                	cmp    %edx,%ecx
  801119:	0f 46 d1             	cmovbe %ecx,%edx
  80111c:	89 55 cc             	mov    %edx,-0x34(%ebp)

	for (pos = offset; pos < offset + count; ) {
  80111f:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  801122:	89 d0                	mov    %edx,%eax
  801124:	01 d8                	add    %ebx,%eax
  801126:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  801129:	39 d8                	cmp    %ebx,%eax
  80112b:	76 6d                	jbe    80119a <file_read+0xad>
		if ((r = file_get_block(f, pos / BLKSIZE, &blk)) < 0)
  80112d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801130:	89 44 24 08          	mov    %eax,0x8(%esp)
  801134:	8d 83 ff 0f 00 00    	lea    0xfff(%ebx),%eax
  80113a:	85 db                	test   %ebx,%ebx
  80113c:	0f 49 c3             	cmovns %ebx,%eax
  80113f:	c1 f8 0c             	sar    $0xc,%eax
  801142:	89 44 24 04          	mov    %eax,0x4(%esp)
  801146:	8b 45 08             	mov    0x8(%ebp),%eax
  801149:	89 04 24             	mov    %eax,(%esp)
  80114c:	e8 0a fb ff ff       	call   800c5b <file_get_block>
  801151:	85 c0                	test   %eax,%eax
  801153:	78 48                	js     80119d <file_read+0xb0>
			return r;
		bn = MIN(BLKSIZE - pos % BLKSIZE, offset + count - pos);
  801155:	89 da                	mov    %ebx,%edx
  801157:	c1 fa 1f             	sar    $0x1f,%edx
  80115a:	c1 ea 14             	shr    $0x14,%edx
  80115d:	8d 04 13             	lea    (%ebx,%edx,1),%eax
  801160:	25 ff 0f 00 00       	and    $0xfff,%eax
  801165:	29 d0                	sub    %edx,%eax
  801167:	be 00 10 00 00       	mov    $0x1000,%esi
  80116c:	29 c6                	sub    %eax,%esi
  80116e:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  801171:	2b 55 d0             	sub    -0x30(%ebp),%edx
  801174:	39 d6                	cmp    %edx,%esi
  801176:	0f 47 f2             	cmova  %edx,%esi
		memmove(buf, blk + pos % BLKSIZE, bn);
  801179:	89 74 24 08          	mov    %esi,0x8(%esp)
  80117d:	03 45 e4             	add    -0x1c(%ebp),%eax
  801180:	89 44 24 04          	mov    %eax,0x4(%esp)
  801184:	89 3c 24             	mov    %edi,(%esp)
  801187:	e8 49 16 00 00       	call   8027d5 <memmove>
		pos += bn;
  80118c:	01 f3                	add    %esi,%ebx
	if (offset >= f->f_size)
		return 0;

	count = MIN(count, f->f_size - offset);

	for (pos = offset; pos < offset + count; ) {
  80118e:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  801191:	39 5d d4             	cmp    %ebx,-0x2c(%ebp)
  801194:	76 04                	jbe    80119a <file_read+0xad>
		if ((r = file_get_block(f, pos / BLKSIZE, &blk)) < 0)
			return r;
		bn = MIN(BLKSIZE - pos % BLKSIZE, offset + count - pos);
		memmove(buf, blk + pos % BLKSIZE, bn);
		pos += bn;
		buf += bn;
  801196:	01 f7                	add    %esi,%edi
  801198:	eb 93                	jmp    80112d <file_read+0x40>
	}

	return count;
  80119a:	8b 45 cc             	mov    -0x34(%ebp),%eax
}
  80119d:	83 c4 3c             	add    $0x3c,%esp
  8011a0:	5b                   	pop    %ebx
  8011a1:	5e                   	pop    %esi
  8011a2:	5f                   	pop    %edi
  8011a3:	5d                   	pop    %ebp
  8011a4:	c3                   	ret    

008011a5 <file_create>:

// Create "path".  On success set *pf to point at the file and return 0.
// On error return < 0.
int
file_create(const char *path, struct File **pf)
{
  8011a5:	55                   	push   %ebp
  8011a6:	89 e5                	mov    %esp,%ebp
  8011a8:	57                   	push   %edi
  8011a9:	56                   	push   %esi
  8011aa:	53                   	push   %ebx
  8011ab:	81 ec bc 00 00 00    	sub    $0xbc,%esp
	char name[MAXNAMELEN];
	int r;
	struct File *dir, *f;

	if ((r = walk_path(path, &dir, &f, name)) == 0)
  8011b1:	8d 8d 60 ff ff ff    	lea    -0xa0(%ebp),%ecx
  8011b7:	8d 95 64 ff ff ff    	lea    -0x9c(%ebp),%edx
  8011bd:	8d 85 68 ff ff ff    	lea    -0x98(%ebp),%eax
  8011c3:	89 04 24             	mov    %eax,(%esp)
  8011c6:	8b 45 08             	mov    0x8(%ebp),%eax
  8011c9:	e8 96 fb ff ff       	call   800d64 <walk_path>
  8011ce:	89 c3                	mov    %eax,%ebx
  8011d0:	85 c0                	test   %eax,%eax
  8011d2:	0f 84 ed 00 00 00    	je     8012c5 <file_create+0x120>
		return -E_FILE_EXISTS;
	if (r != -E_NOT_FOUND || dir == 0)
  8011d8:	83 f8 f5             	cmp    $0xfffffff5,%eax
  8011db:	0f 85 e9 00 00 00    	jne    8012ca <file_create+0x125>
  8011e1:	8b bd 64 ff ff ff    	mov    -0x9c(%ebp),%edi
  8011e7:	85 ff                	test   %edi,%edi
  8011e9:	0f 84 db 00 00 00    	je     8012ca <file_create+0x125>
	int r;
	uint32_t nblock, i, j;
	char *blk;
	struct File *f;

	assert((dir->f_size % BLKSIZE) == 0);
  8011ef:	8b 87 80 00 00 00    	mov    0x80(%edi),%eax
  8011f5:	a9 ff 0f 00 00       	test   $0xfff,%eax
  8011fa:	74 24                	je     801220 <file_create+0x7b>
  8011fc:	c7 44 24 0c 37 49 80 	movl   $0x804937,0xc(%esp)
  801203:	00 
  801204:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  80120b:	00 
  80120c:	c7 44 24 04 f6 00 00 	movl   $0xf6,0x4(%esp)
  801213:	00 
  801214:	c7 04 24 80 48 80 00 	movl   $0x804880,(%esp)
  80121b:	e8 60 0c 00 00       	call   801e80 <_panic>
	nblock = dir->f_size / BLKSIZE;
  801220:	8d 90 ff 0f 00 00    	lea    0xfff(%eax),%edx
  801226:	85 c0                	test   %eax,%eax
  801228:	0f 48 c2             	cmovs  %edx,%eax
  80122b:	c1 f8 0c             	sar    $0xc,%eax
  80122e:	89 85 54 ff ff ff    	mov    %eax,-0xac(%ebp)
	for (i = 0; i < nblock; i++) {
  801234:	be 00 00 00 00       	mov    $0x0,%esi
  801239:	85 c0                	test   %eax,%eax
  80123b:	74 56                	je     801293 <file_create+0xee>
		if ((r = file_get_block(dir, i, &blk)) < 0)
  80123d:	8d 85 5c ff ff ff    	lea    -0xa4(%ebp),%eax
  801243:	89 44 24 08          	mov    %eax,0x8(%esp)
  801247:	89 74 24 04          	mov    %esi,0x4(%esp)
  80124b:	89 3c 24             	mov    %edi,(%esp)
  80124e:	e8 08 fa ff ff       	call   800c5b <file_get_block>
  801253:	85 c0                	test   %eax,%eax
  801255:	78 73                	js     8012ca <file_create+0x125>
			return r;
		f = (struct File*) blk;
  801257:	8b 8d 5c ff ff ff    	mov    -0xa4(%ebp),%ecx
  80125d:	89 ca                	mov    %ecx,%edx
		for (j = 0; j < BLKFILES; j++)
			if (f[j].f_name[0] == '\0') {
  80125f:	80 39 00             	cmpb   $0x0,(%ecx)
  801262:	74 13                	je     801277 <file_create+0xd2>
  801264:	8d 81 00 01 00 00    	lea    0x100(%ecx),%eax
// --------------------------------------------------------------

// Create "path".  On success set *pf to point at the file and return 0.
// On error return < 0.
int
file_create(const char *path, struct File **pf)
  80126a:	81 c1 00 10 00 00    	add    $0x1000,%ecx
  801270:	89 c2                	mov    %eax,%edx
	for (i = 0; i < nblock; i++) {
		if ((r = file_get_block(dir, i, &blk)) < 0)
			return r;
		f = (struct File*) blk;
		for (j = 0; j < BLKFILES; j++)
			if (f[j].f_name[0] == '\0') {
  801272:	80 38 00             	cmpb   $0x0,(%eax)
  801275:	75 08                	jne    80127f <file_create+0xda>
				*file = &f[j];
  801277:	89 95 60 ff ff ff    	mov    %edx,-0xa0(%ebp)
  80127d:	eb 58                	jmp    8012d7 <file_create+0x132>
  80127f:	05 00 01 00 00       	add    $0x100,%eax
	nblock = dir->f_size / BLKSIZE;
	for (i = 0; i < nblock; i++) {
		if ((r = file_get_block(dir, i, &blk)) < 0)
			return r;
		f = (struct File*) blk;
		for (j = 0; j < BLKFILES; j++)
  801284:	39 c8                	cmp    %ecx,%eax
  801286:	75 e8                	jne    801270 <file_create+0xcb>
	char *blk;
	struct File *f;

	assert((dir->f_size % BLKSIZE) == 0);
	nblock = dir->f_size / BLKSIZE;
	for (i = 0; i < nblock; i++) {
  801288:	83 c6 01             	add    $0x1,%esi
  80128b:	39 b5 54 ff ff ff    	cmp    %esi,-0xac(%ebp)
  801291:	77 aa                	ja     80123d <file_create+0x98>
			if (f[j].f_name[0] == '\0') {
				*file = &f[j];
				return 0;
			}
	}
	dir->f_size += BLKSIZE;
  801293:	81 87 80 00 00 00 00 	addl   $0x1000,0x80(%edi)
  80129a:	10 00 00 
	if ((r = file_get_block(dir, i, &blk)) < 0)
  80129d:	8d 85 5c ff ff ff    	lea    -0xa4(%ebp),%eax
  8012a3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8012a7:	89 74 24 04          	mov    %esi,0x4(%esp)
  8012ab:	89 3c 24             	mov    %edi,(%esp)
  8012ae:	e8 a8 f9 ff ff       	call   800c5b <file_get_block>
  8012b3:	85 c0                	test   %eax,%eax
  8012b5:	78 13                	js     8012ca <file_create+0x125>
		return r;
	f = (struct File*) blk;
	*file = &f[0];
  8012b7:	8b 85 5c ff ff ff    	mov    -0xa4(%ebp),%eax
  8012bd:	89 85 60 ff ff ff    	mov    %eax,-0xa0(%ebp)
  8012c3:	eb 12                	jmp    8012d7 <file_create+0x132>
  8012c5:	bb f3 ff ff ff       	mov    $0xfffffff3,%ebx
		return r;
	strcpy(f->f_name, name);
	*pf = f;
	file_flush(dir);
	return 0;
}
  8012ca:	89 d8                	mov    %ebx,%eax
  8012cc:	81 c4 bc 00 00 00    	add    $0xbc,%esp
  8012d2:	5b                   	pop    %ebx
  8012d3:	5e                   	pop    %esi
  8012d4:	5f                   	pop    %edi
  8012d5:	5d                   	pop    %ebp
  8012d6:	c3                   	ret    
		return -E_FILE_EXISTS;
	if (r != -E_NOT_FOUND || dir == 0)
		return r;
	if (dir_alloc_file(dir, &f) < 0)
		return r;
	strcpy(f->f_name, name);
  8012d7:	8d 85 68 ff ff ff    	lea    -0x98(%ebp),%eax
  8012dd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012e1:	8b 85 60 ff ff ff    	mov    -0xa0(%ebp),%eax
  8012e7:	89 04 24             	mov    %eax,(%esp)
  8012ea:	e8 2b 13 00 00       	call   80261a <strcpy>
	*pf = f;
  8012ef:	8b 95 60 ff ff ff    	mov    -0xa0(%ebp),%edx
  8012f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8012f8:	89 10                	mov    %edx,(%eax)
	file_flush(dir);
  8012fa:	8b 85 64 ff ff ff    	mov    -0x9c(%ebp),%eax
  801300:	89 04 24             	mov    %eax,(%esp)
  801303:	e8 b2 f8 ff ff       	call   800bba <file_flush>
  801308:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  80130d:	eb bb                	jmp    8012ca <file_create+0x125>

0080130f <fs_init>:
// --------------------------------------------------------------

// Initialize the file system
void
fs_init(void)
{
  80130f:	55                   	push   %ebp
  801310:	89 e5                	mov    %esp,%ebp
  801312:	83 ec 18             	sub    $0x18,%esp
	static_assert(sizeof(struct File) == 256);

	// Find a JOS disk.  Use the second IDE disk (number 1) if available.
	if (ide_probe_disk1())
  801315:	e8 0a ef ff ff       	call   800224 <ide_probe_disk1>
  80131a:	85 c0                	test   %eax,%eax
  80131c:	74 0e                	je     80132c <fs_init+0x1d>
		ide_set_disk(1);
  80131e:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  801325:	e8 c9 ee ff ff       	call   8001f3 <ide_set_disk>
  80132a:	eb 0c                	jmp    801338 <fs_init+0x29>
	else
		ide_set_disk(0);
  80132c:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801333:	e8 bb ee ff ff       	call   8001f3 <ide_set_disk>
	
	bc_init();
  801338:	e8 c8 f3 ff ff       	call   800705 <bc_init>

	// Set "super" to point to the super block.
	super = diskaddr(1);
  80133d:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  801344:	e8 8a ef ff ff       	call   8002d3 <diskaddr>
  801349:	a3 dc d0 80 00       	mov    %eax,0x80d0dc
	// Set "bitmap" to the beginning of the first bitmap block.
	bitmap = diskaddr(2);
  80134e:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
  801355:	e8 79 ef ff ff       	call   8002d3 <diskaddr>
  80135a:	a3 d8 d0 80 00       	mov    %eax,0x80d0d8

	check_super();
  80135f:	e8 f8 f5 ff ff       	call   80095c <check_super>
	check_bitmap();
  801364:	e8 20 f5 ff ff       	call   800889 <check_bitmap>
}
  801369:	c9                   	leave  
  80136a:	c3                   	ret    
  80136b:	00 00                	add    %al,(%eax)
  80136d:	00 00                	add    %al,(%eax)
	...

00801370 <serve_init>:
// Virtual address at which to receive page mappings containing client requests.
union Fsipc *fsreq = (union Fsipc *)0x0ffff000;

void
serve_init(void)
{
  801370:	55                   	push   %ebp
  801371:	89 e5                	mov    %esp,%ebp
  801373:	ba 20 90 80 00       	mov    $0x809020,%edx
  801378:	b9 00 00 00 00       	mov    $0x0,%ecx
  80137d:	b8 00 00 00 d0       	mov    $0xd0000000,%eax
	int i;
	uintptr_t va = FILEVA;
	for (i = 0; i < MAXOPEN; i++) {
		opentab[i].o_fileid = i;
  801382:	89 0a                	mov    %ecx,(%edx)
		opentab[i].o_fd = (struct Fd*) va;
  801384:	89 42 0c             	mov    %eax,0xc(%edx)
		va += PGSIZE;
  801387:	05 00 10 00 00       	add    $0x1000,%eax
void
serve_init(void)
{
	int i;
	uintptr_t va = FILEVA;
	for (i = 0; i < MAXOPEN; i++) {
  80138c:	83 c1 01             	add    $0x1,%ecx
  80138f:	83 c2 10             	add    $0x10,%edx
  801392:	3d 00 00 40 d0       	cmp    $0xd0400000,%eax
  801397:	75 e9                	jne    801382 <serve_init+0x12>
		opentab[i].o_fileid = i;
		opentab[i].o_fd = (struct Fd*) va;
		va += PGSIZE;
	}
}
  801399:	5d                   	pop    %ebp
  80139a:	c3                   	ret    

0080139b <serve_sync>:
}

// Sync the file system.
int
serve_sync(envid_t envid, union Fsipc *req)
{
  80139b:	55                   	push   %ebp
  80139c:	89 e5                	mov    %esp,%ebp
  80139e:	83 ec 08             	sub    $0x8,%esp
	fs_sync();
  8013a1:	e8 ca f3 ff ff       	call   800770 <fs_sync>
	return 0;
}
  8013a6:	b8 00 00 00 00       	mov    $0x0,%eax
  8013ab:	c9                   	leave  
  8013ac:	c3                   	ret    

008013ad <serve_remove>:
}

// Remove the file req->req_path.
int
serve_remove(envid_t envid, struct Fsreq_remove *req)
{
  8013ad:	55                   	push   %ebp
  8013ae:	89 e5                	mov    %esp,%ebp
  8013b0:	53                   	push   %ebx
  8013b1:	81 ec 14 04 00 00    	sub    $0x414,%esp

	// Delete the named file.
	// Note: This request doesn't refer to an open file.

	// Copy in the path, making sure it's null-terminated
	memmove(path, req->req_path, MAXPATHLEN);
  8013b7:	c7 44 24 08 00 04 00 	movl   $0x400,0x8(%esp)
  8013be:	00 
  8013bf:	8b 45 0c             	mov    0xc(%ebp),%eax
  8013c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013c6:	8d 9d f8 fb ff ff    	lea    -0x408(%ebp),%ebx
  8013cc:	89 1c 24             	mov    %ebx,(%esp)
  8013cf:	e8 01 14 00 00       	call   8027d5 <memmove>
	path[MAXPATHLEN-1] = 0;
  8013d4:	c6 45 f7 00          	movb   $0x0,-0x9(%ebp)

	// Delete the specified file
	return file_remove(path);
  8013d8:	89 1c 24             	mov    %ebx,(%esp)
  8013db:	e8 d9 fb ff ff       	call   800fb9 <file_remove>
}
  8013e0:	81 c4 14 04 00 00    	add    $0x414,%esp
  8013e6:	5b                   	pop    %ebx
  8013e7:	5d                   	pop    %ebp
  8013e8:	c3                   	ret    

008013e9 <openfile_lookup>:
}

// Look up an open file for envid.
int
openfile_lookup(envid_t envid, uint32_t fileid, struct OpenFile **po)
{
  8013e9:	55                   	push   %ebp
  8013ea:	89 e5                	mov    %esp,%ebp
  8013ec:	83 ec 18             	sub    $0x18,%esp
  8013ef:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8013f2:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8013f5:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct OpenFile *o;

	o = &opentab[fileid % MAXOPEN];
  8013f8:	89 f3                	mov    %esi,%ebx
  8013fa:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
  801400:	c1 e3 04             	shl    $0x4,%ebx
  801403:	81 c3 20 90 80 00    	add    $0x809020,%ebx
	if (pageref(o->o_fd) == 1 || o->o_fileid != fileid)
  801409:	8b 43 0c             	mov    0xc(%ebx),%eax
  80140c:	89 04 24             	mov    %eax,(%esp)
  80140f:	e8 14 25 00 00       	call   803928 <pageref>
  801414:	83 f8 01             	cmp    $0x1,%eax
  801417:	74 10                	je     801429 <openfile_lookup+0x40>
  801419:	39 33                	cmp    %esi,(%ebx)
  80141b:	75 0c                	jne    801429 <openfile_lookup+0x40>
		return -E_INVAL;
	*po = o;
  80141d:	8b 45 10             	mov    0x10(%ebp),%eax
  801420:	89 18                	mov    %ebx,(%eax)
  801422:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  801427:	eb 05                	jmp    80142e <openfile_lookup+0x45>
  801429:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  80142e:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801431:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801434:	89 ec                	mov    %ebp,%esp
  801436:	5d                   	pop    %ebp
  801437:	c3                   	ret    

00801438 <serve_flush>:
}

// Flush all data and metadata of req->req_fileid to disk.
int
serve_flush(envid_t envid, struct Fsreq_flush *req)
{
  801438:	55                   	push   %ebp
  801439:	89 e5                	mov    %esp,%ebp
  80143b:	83 ec 28             	sub    $0x28,%esp
	int r;

	if (debug)
		cprintf("serve_flush %08x %08x\n", envid, req->req_fileid);

	if ((r = openfile_lookup(envid, req->req_fileid, &o)) < 0)
  80143e:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801441:	89 44 24 08          	mov    %eax,0x8(%esp)
  801445:	8b 45 0c             	mov    0xc(%ebp),%eax
  801448:	8b 00                	mov    (%eax),%eax
  80144a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80144e:	8b 45 08             	mov    0x8(%ebp),%eax
  801451:	89 04 24             	mov    %eax,(%esp)
  801454:	e8 90 ff ff ff       	call   8013e9 <openfile_lookup>
  801459:	85 c0                	test   %eax,%eax
  80145b:	78 13                	js     801470 <serve_flush+0x38>
		return r;
	file_flush(o->o_file);
  80145d:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801460:	8b 40 04             	mov    0x4(%eax),%eax
  801463:	89 04 24             	mov    %eax,(%esp)
  801466:	e8 4f f7 ff ff       	call   800bba <file_flush>
  80146b:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801470:	c9                   	leave  
  801471:	c3                   	ret    

00801472 <serve_stat>:

// Stat ipc->stat.req_fileid.  Return the file's struct Stat to the
// caller in ipc->statRet.
int
serve_stat(envid_t envid, union Fsipc *ipc)
{
  801472:	55                   	push   %ebp
  801473:	89 e5                	mov    %esp,%ebp
  801475:	53                   	push   %ebx
  801476:	83 ec 24             	sub    $0x24,%esp
  801479:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	if (debug)
		cprintf("serve_stat %08x %08x\n", envid, req->req_fileid);

	if ((r = openfile_lookup(envid, req->req_fileid, &o)) < 0)
  80147c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80147f:	89 44 24 08          	mov    %eax,0x8(%esp)
  801483:	8b 03                	mov    (%ebx),%eax
  801485:	89 44 24 04          	mov    %eax,0x4(%esp)
  801489:	8b 45 08             	mov    0x8(%ebp),%eax
  80148c:	89 04 24             	mov    %eax,(%esp)
  80148f:	e8 55 ff ff ff       	call   8013e9 <openfile_lookup>
  801494:	85 c0                	test   %eax,%eax
  801496:	78 3f                	js     8014d7 <serve_stat+0x65>
		return r;

	strcpy(ret->ret_name, o->o_file->f_name);
  801498:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80149b:	8b 40 04             	mov    0x4(%eax),%eax
  80149e:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014a2:	89 1c 24             	mov    %ebx,(%esp)
  8014a5:	e8 70 11 00 00       	call   80261a <strcpy>
	ret->ret_size = o->o_file->f_size;
  8014aa:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8014ad:	8b 50 04             	mov    0x4(%eax),%edx
  8014b0:	8b 92 80 00 00 00    	mov    0x80(%edx),%edx
  8014b6:	89 93 80 00 00 00    	mov    %edx,0x80(%ebx)
	ret->ret_isdir = (o->o_file->f_type == FTYPE_DIR);
  8014bc:	8b 40 04             	mov    0x4(%eax),%eax
  8014bf:	83 b8 84 00 00 00 01 	cmpl   $0x1,0x84(%eax)
  8014c6:	0f 94 c0             	sete   %al
  8014c9:	0f b6 c0             	movzbl %al,%eax
  8014cc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  8014d2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8014d7:	83 c4 24             	add    $0x24,%esp
  8014da:	5b                   	pop    %ebx
  8014db:	5d                   	pop    %ebp
  8014dc:	c3                   	ret    

008014dd <serve_write>:
// the current seek position, and update the seek position
// accordingly.  Extend the file if necessary.  Returns the number of
// bytes written, or < 0 on error.
int
serve_write(envid_t envid, struct Fsreq_write *req)
{
  8014dd:	55                   	push   %ebp
  8014de:	89 e5                	mov    %esp,%ebp
  8014e0:	53                   	push   %ebx
  8014e1:	83 ec 24             	sub    $0x24,%esp
  8014e4:	8b 5d 0c             	mov    0xc(%ebp),%ebx
    int r;
    struct OpenFile *o  = NULL;
  8014e7:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
	if (debug)
		cprintf("serve_write %08x %08x %08x\n", envid, req->req_fileid, req->req_n);

    if (req->req_n > (PGSIZE - (sizeof(int) + sizeof(size_t))))
  8014ee:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8014f3:	81 7b 04 f8 0f 00 00 	cmpl   $0xff8,0x4(%ebx)
  8014fa:	77 4f                	ja     80154b <serve_write+0x6e>
        return -E_INVAL;

	if ((r = openfile_lookup(envid, req->req_fileid, &o)) < 0)
  8014fc:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8014ff:	89 44 24 08          	mov    %eax,0x8(%esp)
  801503:	8b 03                	mov    (%ebx),%eax
  801505:	89 44 24 04          	mov    %eax,0x4(%esp)
  801509:	8b 45 08             	mov    0x8(%ebp),%eax
  80150c:	89 04 24             	mov    %eax,(%esp)
  80150f:	e8 d5 fe ff ff       	call   8013e9 <openfile_lookup>
  801514:	85 c0                	test   %eax,%eax
  801516:	78 33                	js     80154b <serve_write+0x6e>
		return r;
     
    if ((r = file_write(o->o_file, req->req_buf, req->req_n, o->o_fd->fd_offset))<0)
  801518:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80151b:	8b 50 0c             	mov    0xc(%eax),%edx
  80151e:	8b 52 04             	mov    0x4(%edx),%edx
  801521:	89 54 24 0c          	mov    %edx,0xc(%esp)
  801525:	8b 53 04             	mov    0x4(%ebx),%edx
  801528:	89 54 24 08          	mov    %edx,0x8(%esp)
  80152c:	83 c3 08             	add    $0x8,%ebx
  80152f:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801533:	8b 40 04             	mov    0x4(%eax),%eax
  801536:	89 04 24             	mov    %eax,(%esp)
  801539:	e8 ed fa ff ff       	call   80102b <file_write>
  80153e:	85 c0                	test   %eax,%eax
  801540:	78 09                	js     80154b <serve_write+0x6e>
        return r;
    o->o_fd->fd_offset  += r;
  801542:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801545:	8b 52 0c             	mov    0xc(%edx),%edx
  801548:	01 42 04             	add    %eax,0x4(%edx)
    return r;
}
  80154b:	83 c4 24             	add    $0x24,%esp
  80154e:	5b                   	pop    %ebx
  80154f:	5d                   	pop    %ebp
  801550:	c3                   	ret    

00801551 <serve_read>:
// in ipc->read.req_fileid.  Return the bytes read from the file to
// the caller in ipc->readRet, then update the seek position.  Returns
// the number of bytes successfully read, or < 0 on error.
int
serve_read(envid_t envid, union Fsipc *ipc)
{
  801551:	55                   	push   %ebp
  801552:	89 e5                	mov    %esp,%ebp
  801554:	53                   	push   %ebx
  801555:	83 ec 24             	sub    $0x24,%esp
  801558:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	struct Fsreq_read *req = &ipc->read;
	struct Fsret_read *ret = &ipc->readRet;
  int r;
  struct OpenFile *o  = NULL;
  80155b:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
// the caller in ipc->readRet, then update the seek position.  Returns
// the number of bytes successfully read, or < 0 on error.
int
serve_read(envid_t envid, union Fsipc *ipc)
{
	struct Fsreq_read *req = &ipc->read;
  801562:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801567:	81 7b 04 00 10 00 00 	cmpl   $0x1000,0x4(%ebx)
  80156e:	77 4c                	ja     8015bc <serve_read+0x6b>
	// so filling in ret will overwrite req.
	//
	// Hint: Use file_read.
	// Hint: The seek position is stored in the struct Fd.
	// LAB 5: Your code here
	if ((r = openfile_lookup(envid, req->req_fileid, &o)) < 0)
  801570:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801573:	89 44 24 08          	mov    %eax,0x8(%esp)
  801577:	8b 03                	mov    (%ebx),%eax
  801579:	89 44 24 04          	mov    %eax,0x4(%esp)
  80157d:	8b 45 08             	mov    0x8(%ebp),%eax
  801580:	89 04 24             	mov    %eax,(%esp)
  801583:	e8 61 fe ff ff       	call   8013e9 <openfile_lookup>
  801588:	85 c0                	test   %eax,%eax
  80158a:	78 30                	js     8015bc <serve_read+0x6b>
		return r;
     
  if ((r = file_read(o->o_file, ret, req->req_n, o->o_fd->fd_offset))<0)
  80158c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80158f:	8b 50 0c             	mov    0xc(%eax),%edx
  801592:	8b 52 04             	mov    0x4(%edx),%edx
  801595:	89 54 24 0c          	mov    %edx,0xc(%esp)
  801599:	8b 53 04             	mov    0x4(%ebx),%edx
  80159c:	89 54 24 08          	mov    %edx,0x8(%esp)
  8015a0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8015a4:	8b 40 04             	mov    0x4(%eax),%eax
  8015a7:	89 04 24             	mov    %eax,(%esp)
  8015aa:	e8 3e fb ff ff       	call   8010ed <file_read>
  8015af:	85 c0                	test   %eax,%eax
  8015b1:	78 09                	js     8015bc <serve_read+0x6b>
    return r;

  o->o_fd->fd_offset  += r;
  8015b3:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8015b6:	8b 52 0c             	mov    0xc(%edx),%edx
  8015b9:	01 42 04             	add    %eax,0x4(%edx)
  return r;
}
  8015bc:	83 c4 24             	add    $0x24,%esp
  8015bf:	5b                   	pop    %ebx
  8015c0:	5d                   	pop    %ebp
  8015c1:	c3                   	ret    

008015c2 <serve_set_size>:

// Set the size of req->req_fileid to req->req_size bytes, truncating
// or extending the file as necessary.
int
serve_set_size(envid_t envid, struct Fsreq_set_size *req)
{
  8015c2:	55                   	push   %ebp
  8015c3:	89 e5                	mov    %esp,%ebp
  8015c5:	53                   	push   %ebx
  8015c6:	83 ec 24             	sub    $0x24,%esp
  8015c9:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// Every file system IPC call has the same general structure.
	// Here's how it goes.

	// First, use openfile_lookup to find the relevant open file.
	// On failure, return the error code to the client with ipc_send.
	if ((r = openfile_lookup(envid, req->req_fileid, &o)) < 0)
  8015cc:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8015cf:	89 44 24 08          	mov    %eax,0x8(%esp)
  8015d3:	8b 03                	mov    (%ebx),%eax
  8015d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015d9:	8b 45 08             	mov    0x8(%ebp),%eax
  8015dc:	89 04 24             	mov    %eax,(%esp)
  8015df:	e8 05 fe ff ff       	call   8013e9 <openfile_lookup>
  8015e4:	85 c0                	test   %eax,%eax
  8015e6:	78 15                	js     8015fd <serve_set_size+0x3b>
		return r;

	// Second, call the relevant file system function (from fs/fs.c).
	// On failure, return the error code to the client.
	return file_set_size(o->o_file, req->req_size);
  8015e8:	8b 43 04             	mov    0x4(%ebx),%eax
  8015eb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015ef:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8015f2:	8b 40 04             	mov    0x4(%eax),%eax
  8015f5:	89 04 24             	mov    %eax,(%esp)
  8015f8:	e8 7d f5 ff ff       	call   800b7a <file_set_size>
}
  8015fd:	83 c4 24             	add    $0x24,%esp
  801600:	5b                   	pop    %ebx
  801601:	5d                   	pop    %ebp
  801602:	c3                   	ret    

00801603 <openfile_alloc>:
}

// Allocate an open file.
int
openfile_alloc(struct OpenFile **o)
{
  801603:	55                   	push   %ebp
  801604:	89 e5                	mov    %esp,%ebp
  801606:	83 ec 28             	sub    $0x28,%esp
  801609:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80160c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80160f:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801612:	8b 7d 08             	mov    0x8(%ebp),%edi
  801615:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i, r;

	// Find an available open-file table entry
	for (i = 0; i < MAXOPEN; i++) {
		switch (pageref(opentab[i].o_fd)) {
  80161a:	be 2c 90 80 00       	mov    $0x80902c,%esi
  80161f:	89 d8                	mov    %ebx,%eax
  801621:	c1 e0 04             	shl    $0x4,%eax
  801624:	8b 04 30             	mov    (%eax,%esi,1),%eax
  801627:	89 04 24             	mov    %eax,(%esp)
  80162a:	e8 f9 22 00 00       	call   803928 <pageref>
  80162f:	85 c0                	test   %eax,%eax
  801631:	74 07                	je     80163a <openfile_alloc+0x37>
  801633:	83 f8 01             	cmp    $0x1,%eax
  801636:	75 62                	jne    80169a <openfile_alloc+0x97>
  801638:	eb 27                	jmp    801661 <openfile_alloc+0x5e>
		case 0:
			if ((r = sys_page_alloc(0, opentab[i].o_fd, PTE_P|PTE_U|PTE_W)) < 0)
  80163a:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801641:	00 
  801642:	89 d8                	mov    %ebx,%eax
  801644:	c1 e0 04             	shl    $0x4,%eax
  801647:	8b 80 2c 90 80 00    	mov    0x80902c(%eax),%eax
  80164d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801651:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801658:	e8 19 17 00 00       	call   802d76 <sys_page_alloc>
  80165d:	85 c0                	test   %eax,%eax
  80165f:	78 4d                	js     8016ae <openfile_alloc+0xab>
				return r;
			/* fall through */
		case 1:
			opentab[i].o_fileid += MAXOPEN;
  801661:	c1 e3 04             	shl    $0x4,%ebx
  801664:	81 83 20 90 80 00 00 	addl   $0x400,0x809020(%ebx)
  80166b:	04 00 00 
			*o = &opentab[i];
  80166e:	8d 83 20 90 80 00    	lea    0x809020(%ebx),%eax
  801674:	89 07                	mov    %eax,(%edi)
			memset(opentab[i].o_fd, 0, PGSIZE);
  801676:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  80167d:	00 
  80167e:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801685:	00 
  801686:	8b 83 2c 90 80 00    	mov    0x80902c(%ebx),%eax
  80168c:	89 04 24             	mov    %eax,(%esp)
  80168f:	e8 e2 10 00 00       	call   802776 <memset>
			return (*o)->o_fileid;
  801694:	8b 07                	mov    (%edi),%eax
  801696:	8b 00                	mov    (%eax),%eax
  801698:	eb 14                	jmp    8016ae <openfile_alloc+0xab>
openfile_alloc(struct OpenFile **o)
{
	int i, r;

	// Find an available open-file table entry
	for (i = 0; i < MAXOPEN; i++) {
  80169a:	83 c3 01             	add    $0x1,%ebx
  80169d:	81 fb 00 04 00 00    	cmp    $0x400,%ebx
  8016a3:	0f 85 76 ff ff ff    	jne    80161f <openfile_alloc+0x1c>
  8016a9:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
			memset(opentab[i].o_fd, 0, PGSIZE);
			return (*o)->o_fileid;
		}
	}
	return -E_MAX_OPEN;
}
  8016ae:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8016b1:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8016b4:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8016b7:	89 ec                	mov    %ebp,%esp
  8016b9:	5d                   	pop    %ebp
  8016ba:	c3                   	ret    

008016bb <serve_open>:
// permissions to return to the calling environment in *pg_store and
// *perm_store respectively.
int
serve_open(envid_t envid, struct Fsreq_open *req,
	   void **pg_store, int *perm_store)
{
  8016bb:	55                   	push   %ebp
  8016bc:	89 e5                	mov    %esp,%ebp
  8016be:	53                   	push   %ebx
  8016bf:	81 ec 24 04 00 00    	sub    $0x424,%esp
  8016c5:	8b 5d 0c             	mov    0xc(%ebp),%ebx
    
	if (debug)
		cprintf("serve_open %08x %s 0x%x\n", envid, req->req_path, req->req_omode);

	// Copy in the path, making sure it's null-terminated
	memmove(path, req->req_path, MAXPATHLEN);
  8016c8:	c7 44 24 08 00 04 00 	movl   $0x400,0x8(%esp)
  8016cf:	00 
  8016d0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8016d4:	8d 85 f8 fb ff ff    	lea    -0x408(%ebp),%eax
  8016da:	89 04 24             	mov    %eax,(%esp)
  8016dd:	e8 f3 10 00 00       	call   8027d5 <memmove>
	path[MAXPATHLEN-1] = 0;
  8016e2:	c6 45 f7 00          	movb   $0x0,-0x9(%ebp)

	// Find an open file ID
	if ((r = openfile_alloc(&o)) < 0) {
  8016e6:	8d 85 f0 fb ff ff    	lea    -0x410(%ebp),%eax
  8016ec:	89 04 24             	mov    %eax,(%esp)
  8016ef:	e8 0f ff ff ff       	call   801603 <openfile_alloc>
  8016f4:	85 c0                	test   %eax,%eax
  8016f6:	0f 88 ec 00 00 00    	js     8017e8 <serve_open+0x12d>
		return r;
	}
	fileid = r;

	// Open the file
	if (req->req_omode & O_CREAT) {
  8016fc:	f6 83 01 04 00 00 01 	testb  $0x1,0x401(%ebx)
  801703:	74 32                	je     801737 <serve_open+0x7c>
		if ((r = file_create(path, &f)) < 0) {
  801705:	8d 85 f4 fb ff ff    	lea    -0x40c(%ebp),%eax
  80170b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80170f:	8d 85 f8 fb ff ff    	lea    -0x408(%ebp),%eax
  801715:	89 04 24             	mov    %eax,(%esp)
  801718:	e8 88 fa ff ff       	call   8011a5 <file_create>
  80171d:	85 c0                	test   %eax,%eax
  80171f:	79 36                	jns    801757 <serve_open+0x9c>
			if (!(req->req_omode & O_EXCL) && r == -E_FILE_EXISTS)
  801721:	f6 83 01 04 00 00 04 	testb  $0x4,0x401(%ebx)
  801728:	0f 85 ba 00 00 00    	jne    8017e8 <serve_open+0x12d>
  80172e:	83 f8 f3             	cmp    $0xfffffff3,%eax
  801731:	0f 85 b1 00 00 00    	jne    8017e8 <serve_open+0x12d>
				cprintf("file_create failed: %e", r);
			return r;
		}
	} else {
try_open:
		if ((r = file_open(path, &f)) < 0) {
  801737:	8d 85 f4 fb ff ff    	lea    -0x40c(%ebp),%eax
  80173d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801741:	8d 85 f8 fb ff ff    	lea    -0x408(%ebp),%eax
  801747:	89 04 24             	mov    %eax,(%esp)
  80174a:	e8 bd f8 ff ff       	call   80100c <file_open>
  80174f:	85 c0                	test   %eax,%eax
  801751:	0f 88 91 00 00 00    	js     8017e8 <serve_open+0x12d>
			return r;
		}
	}

	// Truncate
	if (req->req_omode & O_TRUNC) {
  801757:	f6 83 01 04 00 00 02 	testb  $0x2,0x401(%ebx)
  80175e:	74 1a                	je     80177a <serve_open+0xbf>
		if ((r = file_set_size(f, 0)) < 0) {
  801760:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801767:	00 
  801768:	8b 85 f4 fb ff ff    	mov    -0x40c(%ebp),%eax
  80176e:	89 04 24             	mov    %eax,(%esp)
  801771:	e8 04 f4 ff ff       	call   800b7a <file_set_size>
  801776:	85 c0                	test   %eax,%eax
  801778:	78 6e                	js     8017e8 <serve_open+0x12d>
			return r;
		}
	}

	// Save the file pointer
	o->o_file = f;
  80177a:	8b 95 f4 fb ff ff    	mov    -0x40c(%ebp),%edx
  801780:	8b 85 f0 fb ff ff    	mov    -0x410(%ebp),%eax
  801786:	89 50 04             	mov    %edx,0x4(%eax)

	// Fill out the Fd structure
	o->o_fd->fd_file.id = o->o_fileid;
  801789:	8b 85 f0 fb ff ff    	mov    -0x410(%ebp),%eax
  80178f:	8b 50 0c             	mov    0xc(%eax),%edx
  801792:	8b 00                	mov    (%eax),%eax
  801794:	89 42 0c             	mov    %eax,0xc(%edx)
	o->o_fd->fd_omode = req->req_omode & O_ACCMODE;
  801797:	8b 85 f0 fb ff ff    	mov    -0x410(%ebp),%eax
  80179d:	8b 40 0c             	mov    0xc(%eax),%eax
  8017a0:	8b 93 00 04 00 00    	mov    0x400(%ebx),%edx
  8017a6:	83 e2 03             	and    $0x3,%edx
  8017a9:	89 50 08             	mov    %edx,0x8(%eax)
	o->o_fd->fd_dev_id = devfile.dev_id;
  8017ac:	8b 85 f0 fb ff ff    	mov    -0x410(%ebp),%eax
  8017b2:	8b 40 0c             	mov    0xc(%eax),%eax
  8017b5:	8b 15 68 d0 80 00    	mov    0x80d068,%edx
  8017bb:	89 10                	mov    %edx,(%eax)
	o->o_mode = req->req_omode;
  8017bd:	8b 93 00 04 00 00    	mov    0x400(%ebx),%edx
  8017c3:	8b 85 f0 fb ff ff    	mov    -0x410(%ebp),%eax
  8017c9:	89 50 08             	mov    %edx,0x8(%eax)

	if (debug)
		cprintf("sending success, page %08x\n", (uintptr_t) o->o_fd);

	// Share the FD page with the caller
	*pg_store = o->o_fd;
  8017cc:	8b 85 f0 fb ff ff    	mov    -0x410(%ebp),%eax
  8017d2:	8b 50 0c             	mov    0xc(%eax),%edx
  8017d5:	8b 45 10             	mov    0x10(%ebp),%eax
  8017d8:	89 10                	mov    %edx,(%eax)
	*perm_store = PTE_P|PTE_U|PTE_W|PTE_SHARE;
  8017da:	8b 45 14             	mov    0x14(%ebp),%eax
  8017dd:	c7 00 07 04 00 00    	movl   $0x407,(%eax)
  8017e3:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8017e8:	81 c4 24 04 00 00    	add    $0x424,%esp
  8017ee:	5b                   	pop    %ebx
  8017ef:	5d                   	pop    %ebp
  8017f0:	c3                   	ret    

008017f1 <serve>:
};
#define NHANDLERS (sizeof(handlers)/sizeof(handlers[0]))

void
serve(void)
{
  8017f1:	55                   	push   %ebp
  8017f2:	89 e5                	mov    %esp,%ebp
  8017f4:	57                   	push   %edi
  8017f5:	56                   	push   %esi
  8017f6:	53                   	push   %ebx
  8017f7:	83 ec 2c             	sub    $0x2c,%esp
	int perm, r;
	void *pg;

	while (1) {
		perm = 0|PTE_SHARE;
		req = ipc_recv((int32_t *) &whom, fsreq, &perm);
  8017fa:	8d 5d e0             	lea    -0x20(%ebp),%ebx
  8017fd:	8d 75 e4             	lea    -0x1c(%ebp),%esi
		}

		pg = NULL;
		if (req == FSREQ_OPEN) {
			r = serve_open(whom, (struct Fsreq_open*)fsreq, &pg, &perm);
		} else if (req < NHANDLERS && handlers[req]) {
  801800:	bf 40 d0 80 00       	mov    $0x80d040,%edi
	uint32_t req, whom;
	int perm, r;
	void *pg;

	while (1) {
		perm = 0|PTE_SHARE;
  801805:	c7 45 e0 00 04 00 00 	movl   $0x400,-0x20(%ebp)
		req = ipc_recv((int32_t *) &whom, fsreq, &perm);
  80180c:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801810:	a1 20 d0 80 00       	mov    0x80d020,%eax
  801815:	89 44 24 04          	mov    %eax,0x4(%esp)
  801819:	89 34 24             	mov    %esi,(%esp)
  80181c:	e8 91 17 00 00       	call   802fb2 <ipc_recv>
		if (debug)
			cprintf("fs req %d from %08x [page %08x: %s]\n",
				req, whom, vpt[VPN(fsreq)], fsreq);

		// All requests must contain an argument page
		if (!(perm & PTE_P)) {
  801821:	f6 45 e0 01          	testb  $0x1,-0x20(%ebp)
  801825:	75 15                	jne    80183c <serve+0x4b>
			cprintf("Invalid request from %08x: no argument page\n",
  801827:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80182a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80182e:	c7 04 24 54 49 80 00 	movl   $0x804954,(%esp)
  801835:	e8 0b 07 00 00       	call   801f45 <cprintf>
				whom);
			continue; // just leave it hanging...
  80183a:	eb c9                	jmp    801805 <serve+0x14>
		}

		pg = NULL;
  80183c:	c7 45 dc 00 00 00 00 	movl   $0x0,-0x24(%ebp)
		if (req == FSREQ_OPEN) {
  801843:	83 f8 01             	cmp    $0x1,%eax
  801846:	75 21                	jne    801869 <serve+0x78>
			r = serve_open(whom, (struct Fsreq_open*)fsreq, &pg, &perm);
  801848:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80184c:	8d 45 dc             	lea    -0x24(%ebp),%eax
  80184f:	89 44 24 08          	mov    %eax,0x8(%esp)
  801853:	a1 20 d0 80 00       	mov    0x80d020,%eax
  801858:	89 44 24 04          	mov    %eax,0x4(%esp)
  80185c:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80185f:	89 04 24             	mov    %eax,(%esp)
  801862:	e8 54 fe ff ff       	call   8016bb <serve_open>
  801867:	eb 3b                	jmp    8018a4 <serve+0xb3>
		} else if (req < NHANDLERS && handlers[req]) {
  801869:	83 f8 08             	cmp    $0x8,%eax
  80186c:	77 1a                	ja     801888 <serve+0x97>
  80186e:	8b 14 87             	mov    (%edi,%eax,4),%edx
  801871:	85 d2                	test   %edx,%edx
  801873:	74 13                	je     801888 <serve+0x97>
			r = handlers[req](whom, fsreq);
  801875:	a1 20 d0 80 00       	mov    0x80d020,%eax
  80187a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80187e:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801881:	89 04 24             	mov    %eax,(%esp)
  801884:	ff d2                	call   *%edx
		}

		pg = NULL;
		if (req == FSREQ_OPEN) {
			r = serve_open(whom, (struct Fsreq_open*)fsreq, &pg, &perm);
		} else if (req < NHANDLERS && handlers[req]) {
  801886:	eb 1c                	jmp    8018a4 <serve+0xb3>
			r = handlers[req](whom, fsreq);
		} else {
			cprintf("Invalid request code %d from %08x\n", whom, req);
  801888:	89 44 24 08          	mov    %eax,0x8(%esp)
  80188c:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80188f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801893:	c7 04 24 84 49 80 00 	movl   $0x804984,(%esp)
  80189a:	e8 a6 06 00 00       	call   801f45 <cprintf>
  80189f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			r = -E_INVAL;
		}
		ipc_send(whom, r, pg, perm);
  8018a4:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8018a7:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8018ab:	8b 55 dc             	mov    -0x24(%ebp),%edx
  8018ae:	89 54 24 08          	mov    %edx,0x8(%esp)
  8018b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018b6:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8018b9:	89 04 24             	mov    %eax,(%esp)
  8018bc:	e8 7f 16 00 00       	call   802f40 <ipc_send>
		sys_page_unmap(0, fsreq);
  8018c1:	a1 20 d0 80 00       	mov    0x80d020,%eax
  8018c6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018ca:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018d1:	e8 e4 13 00 00       	call   802cba <sys_page_unmap>
  8018d6:	e9 2a ff ff ff       	jmp    801805 <serve+0x14>

008018db <umain>:
	}
}

void
umain(void)
{
  8018db:	55                   	push   %ebp
  8018dc:	89 e5                	mov    %esp,%ebp
  8018de:	83 ec 18             	sub    $0x18,%esp
	static_assert(sizeof(struct File) == 256);
	binaryname = "fs";
  8018e1:	c7 05 64 d0 80 00 a7 	movl   $0x8049a7,0x80d064
  8018e8:	49 80 00 
	cprintf("FS is running. %x\n", sys_getenvid());
  8018eb:	e8 19 15 00 00       	call   802e09 <sys_getenvid>
  8018f0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018f4:	c7 04 24 aa 49 80 00 	movl   $0x8049aa,(%esp)
  8018fb:	e8 45 06 00 00       	call   801f45 <cprintf>
}

static __inline void
outw(int port, uint16_t data)
{
	__asm __volatile("outw %0,%w1" : : "a" (data), "d" (port));
  801900:	ba 00 8a 00 00       	mov    $0x8a00,%edx
  801905:	b8 00 8a ff ff       	mov    $0xffff8a00,%eax
  80190a:	66 ef                	out    %ax,(%dx)

	// Check that we are able to do I/O
	outw(0x8A00, 0x8A00);
	cprintf("FS can do I/O\n");
  80190c:	c7 04 24 bd 49 80 00 	movl   $0x8049bd,(%esp)
  801913:	e8 2d 06 00 00       	call   801f45 <cprintf>

	serve_init();
  801918:	e8 53 fa ff ff       	call   801370 <serve_init>
	fs_init();
  80191d:	e8 ed f9 ff ff       	call   80130f <fs_init>
	fs_test();
  801922:	e8 0d 00 00 00       	call   801934 <fs_test>

	serve();
  801927:	e8 c5 fe ff ff       	call   8017f1 <serve>
}
  80192c:	c9                   	leave  
  80192d:	8d 76 00             	lea    0x0(%esi),%esi
  801930:	c3                   	ret    
  801931:	00 00                	add    %al,(%eax)
	...

00801934 <fs_test>:

static char *msg = "This is the NEW message of the day!\n\n";

void
fs_test(void)
{
  801934:	55                   	push   %ebp
  801935:	89 e5                	mov    %esp,%ebp
  801937:	53                   	push   %ebx
  801938:	83 ec 24             	sub    $0x24,%esp
	int r;
	char *blk;
	uint32_t *bits;

	// back up bitmap
	if ((r = sys_page_alloc(0, (void*) PGSIZE, PTE_P|PTE_U|PTE_W)) < 0)
  80193b:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801942:	00 
  801943:	c7 44 24 04 00 10 00 	movl   $0x1000,0x4(%esp)
  80194a:	00 
  80194b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801952:	e8 1f 14 00 00       	call   802d76 <sys_page_alloc>
  801957:	85 c0                	test   %eax,%eax
  801959:	79 20                	jns    80197b <fs_test+0x47>
		panic("sys_page_alloc: %e", r);
  80195b:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80195f:	c7 44 24 08 cc 49 80 	movl   $0x8049cc,0x8(%esp)
  801966:	00 
  801967:	c7 44 24 04 13 00 00 	movl   $0x13,0x4(%esp)
  80196e:	00 
  80196f:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801976:	e8 05 05 00 00       	call   801e80 <_panic>
	bits = (uint32_t*) PGSIZE;
	memmove(bits, bitmap, PGSIZE);
  80197b:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  801982:	00 
  801983:	a1 d8 d0 80 00       	mov    0x80d0d8,%eax
  801988:	89 44 24 04          	mov    %eax,0x4(%esp)
  80198c:	c7 04 24 00 10 00 00 	movl   $0x1000,(%esp)
  801993:	e8 3d 0e 00 00       	call   8027d5 <memmove>
	// allocate block
	if ((r = alloc_block()) < 0)
  801998:	e8 15 ee ff ff       	call   8007b2 <alloc_block>
  80199d:	85 c0                	test   %eax,%eax
  80199f:	79 20                	jns    8019c1 <fs_test+0x8d>
		panic("alloc_block: %e", r);
  8019a1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8019a5:	c7 44 24 08 e9 49 80 	movl   $0x8049e9,0x8(%esp)
  8019ac:	00 
  8019ad:	c7 44 24 04 18 00 00 	movl   $0x18,0x4(%esp)
  8019b4:	00 
  8019b5:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  8019bc:	e8 bf 04 00 00       	call   801e80 <_panic>
	// check that block was free
	assert(bits[r/32] & (1 << (r%32)));
  8019c1:	8d 50 1f             	lea    0x1f(%eax),%edx
  8019c4:	85 c0                	test   %eax,%eax
  8019c6:	0f 49 d0             	cmovns %eax,%edx
  8019c9:	c1 fa 05             	sar    $0x5,%edx
  8019cc:	c1 e2 02             	shl    $0x2,%edx
  8019cf:	89 c3                	mov    %eax,%ebx
  8019d1:	c1 fb 1f             	sar    $0x1f,%ebx
  8019d4:	c1 eb 1b             	shr    $0x1b,%ebx
  8019d7:	8d 0c 18             	lea    (%eax,%ebx,1),%ecx
  8019da:	83 e1 1f             	and    $0x1f,%ecx
  8019dd:	29 d9                	sub    %ebx,%ecx
  8019df:	b8 01 00 00 00       	mov    $0x1,%eax
  8019e4:	d3 e0                	shl    %cl,%eax
  8019e6:	85 82 00 10 00 00    	test   %eax,0x1000(%edx)
  8019ec:	75 24                	jne    801a12 <fs_test+0xde>
  8019ee:	c7 44 24 0c f9 49 80 	movl   $0x8049f9,0xc(%esp)
  8019f5:	00 
  8019f6:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  8019fd:	00 
  8019fe:	c7 44 24 04 1a 00 00 	movl   $0x1a,0x4(%esp)
  801a05:	00 
  801a06:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801a0d:	e8 6e 04 00 00       	call   801e80 <_panic>
	// and is not free any more
	assert(!(bitmap[r/32] & (1 << (r%32))));
  801a12:	8b 0d d8 d0 80 00    	mov    0x80d0d8,%ecx
  801a18:	85 04 11             	test   %eax,(%ecx,%edx,1)
  801a1b:	74 24                	je     801a41 <fs_test+0x10d>
  801a1d:	c7 44 24 0c 6c 4b 80 	movl   $0x804b6c,0xc(%esp)
  801a24:	00 
  801a25:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801a2c:	00 
  801a2d:	c7 44 24 04 1c 00 00 	movl   $0x1c,0x4(%esp)
  801a34:	00 
  801a35:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801a3c:	e8 3f 04 00 00       	call   801e80 <_panic>
	cprintf("alloc_block is good\n");
  801a41:	c7 04 24 14 4a 80 00 	movl   $0x804a14,(%esp)
  801a48:	e8 f8 04 00 00       	call   801f45 <cprintf>

	if ((r = file_open("/not-found", &f)) < 0 && r != -E_NOT_FOUND)
  801a4d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a50:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a54:	c7 04 24 29 4a 80 00 	movl   $0x804a29,(%esp)
  801a5b:	e8 ac f5 ff ff       	call   80100c <file_open>
  801a60:	85 c0                	test   %eax,%eax
  801a62:	79 25                	jns    801a89 <fs_test+0x155>
  801a64:	83 f8 f5             	cmp    $0xfffffff5,%eax
  801a67:	74 40                	je     801aa9 <fs_test+0x175>
		panic("file_open /not-found: %e", r);
  801a69:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801a6d:	c7 44 24 08 34 4a 80 	movl   $0x804a34,0x8(%esp)
  801a74:	00 
  801a75:	c7 44 24 04 20 00 00 	movl   $0x20,0x4(%esp)
  801a7c:	00 
  801a7d:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801a84:	e8 f7 03 00 00       	call   801e80 <_panic>
	else if (r == 0)
  801a89:	85 c0                	test   %eax,%eax
  801a8b:	75 1c                	jne    801aa9 <fs_test+0x175>
		panic("file_open /not-found succeeded!");
  801a8d:	c7 44 24 08 8c 4b 80 	movl   $0x804b8c,0x8(%esp)
  801a94:	00 
  801a95:	c7 44 24 04 22 00 00 	movl   $0x22,0x4(%esp)
  801a9c:	00 
  801a9d:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801aa4:	e8 d7 03 00 00       	call   801e80 <_panic>
	if ((r = file_open("/newmotd", &f)) < 0)
  801aa9:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801aac:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ab0:	c7 04 24 4d 4a 80 00 	movl   $0x804a4d,(%esp)
  801ab7:	e8 50 f5 ff ff       	call   80100c <file_open>
  801abc:	85 c0                	test   %eax,%eax
  801abe:	79 20                	jns    801ae0 <fs_test+0x1ac>
		panic("file_open /newmotd: %e", r);
  801ac0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801ac4:	c7 44 24 08 56 4a 80 	movl   $0x804a56,0x8(%esp)
  801acb:	00 
  801acc:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  801ad3:	00 
  801ad4:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801adb:	e8 a0 03 00 00       	call   801e80 <_panic>
	cprintf("file_open is good\n");
  801ae0:	c7 04 24 6d 4a 80 00 	movl   $0x804a6d,(%esp)
  801ae7:	e8 59 04 00 00       	call   801f45 <cprintf>

	if ((r = file_get_block(f, 0, &blk)) < 0)
  801aec:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801aef:	89 44 24 08          	mov    %eax,0x8(%esp)
  801af3:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801afa:	00 
  801afb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801afe:	89 04 24             	mov    %eax,(%esp)
  801b01:	e8 55 f1 ff ff       	call   800c5b <file_get_block>
  801b06:	85 c0                	test   %eax,%eax
  801b08:	79 20                	jns    801b2a <fs_test+0x1f6>
		panic("file_get_block: %e", r);
  801b0a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801b0e:	c7 44 24 08 80 4a 80 	movl   $0x804a80,0x8(%esp)
  801b15:	00 
  801b16:	c7 44 24 04 28 00 00 	movl   $0x28,0x4(%esp)
  801b1d:	00 
  801b1e:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801b25:	e8 56 03 00 00       	call   801e80 <_panic>
	if (strcmp(blk, msg) != 0)
  801b2a:	8b 1d f8 4b 80 00    	mov    0x804bf8,%ebx
  801b30:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801b34:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801b37:	89 04 24             	mov    %eax,(%esp)
  801b3a:	e8 6a 0b 00 00       	call   8026a9 <strcmp>
  801b3f:	85 c0                	test   %eax,%eax
  801b41:	74 1c                	je     801b5f <fs_test+0x22b>
		panic("file_get_block returned wrong data");
  801b43:	c7 44 24 08 ac 4b 80 	movl   $0x804bac,0x8(%esp)
  801b4a:	00 
  801b4b:	c7 44 24 04 2a 00 00 	movl   $0x2a,0x4(%esp)
  801b52:	00 
  801b53:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801b5a:	e8 21 03 00 00       	call   801e80 <_panic>
	cprintf("file_get_block is good\n");
  801b5f:	c7 04 24 93 4a 80 00 	movl   $0x804a93,(%esp)
  801b66:	e8 da 03 00 00       	call   801f45 <cprintf>

	*(volatile char*)blk = *(volatile char*)blk;
  801b6b:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801b6e:	0f b6 10             	movzbl (%eax),%edx
  801b71:	88 10                	mov    %dl,(%eax)
	assert((vpt[VPN(blk)] & PTE_D));
  801b73:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801b76:	c1 e8 0c             	shr    $0xc,%eax
  801b79:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801b80:	a8 40                	test   $0x40,%al
  801b82:	75 24                	jne    801ba8 <fs_test+0x274>
  801b84:	c7 44 24 0c ac 4a 80 	movl   $0x804aac,0xc(%esp)
  801b8b:	00 
  801b8c:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801b93:	00 
  801b94:	c7 44 24 04 2e 00 00 	movl   $0x2e,0x4(%esp)
  801b9b:	00 
  801b9c:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801ba3:	e8 d8 02 00 00       	call   801e80 <_panic>
	file_flush(f);
  801ba8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801bab:	89 04 24             	mov    %eax,(%esp)
  801bae:	e8 07 f0 ff ff       	call   800bba <file_flush>
	assert(!(vpt[VPN(blk)] & PTE_D));
  801bb3:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801bb6:	c1 e8 0c             	shr    $0xc,%eax
  801bb9:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801bc0:	a8 40                	test   $0x40,%al
  801bc2:	74 24                	je     801be8 <fs_test+0x2b4>
  801bc4:	c7 44 24 0c ab 4a 80 	movl   $0x804aab,0xc(%esp)
  801bcb:	00 
  801bcc:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801bd3:	00 
  801bd4:	c7 44 24 04 30 00 00 	movl   $0x30,0x4(%esp)
  801bdb:	00 
  801bdc:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801be3:	e8 98 02 00 00       	call   801e80 <_panic>
	cprintf("file_flush is good\n");
  801be8:	c7 04 24 c4 4a 80 00 	movl   $0x804ac4,(%esp)
  801bef:	e8 51 03 00 00       	call   801f45 <cprintf>

	if ((r = file_set_size(f, 0)) < 0)
  801bf4:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801bfb:	00 
  801bfc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801bff:	89 04 24             	mov    %eax,(%esp)
  801c02:	e8 73 ef ff ff       	call   800b7a <file_set_size>
  801c07:	85 c0                	test   %eax,%eax
  801c09:	79 20                	jns    801c2b <fs_test+0x2f7>
		panic("file_set_size: %e", r);
  801c0b:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801c0f:	c7 44 24 08 d8 4a 80 	movl   $0x804ad8,0x8(%esp)
  801c16:	00 
  801c17:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  801c1e:	00 
  801c1f:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801c26:	e8 55 02 00 00       	call   801e80 <_panic>
	assert(f->f_direct[0] == 0);
  801c2b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801c2e:	83 b8 88 00 00 00 00 	cmpl   $0x0,0x88(%eax)
  801c35:	74 24                	je     801c5b <fs_test+0x327>
  801c37:	c7 44 24 0c ea 4a 80 	movl   $0x804aea,0xc(%esp)
  801c3e:	00 
  801c3f:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801c46:	00 
  801c47:	c7 44 24 04 35 00 00 	movl   $0x35,0x4(%esp)
  801c4e:	00 
  801c4f:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801c56:	e8 25 02 00 00       	call   801e80 <_panic>
	assert(!(vpt[VPN(f)] & PTE_D));
  801c5b:	c1 e8 0c             	shr    $0xc,%eax
  801c5e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801c65:	a8 40                	test   $0x40,%al
  801c67:	74 24                	je     801c8d <fs_test+0x359>
  801c69:	c7 44 24 0c fe 4a 80 	movl   $0x804afe,0xc(%esp)
  801c70:	00 
  801c71:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801c78:	00 
  801c79:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  801c80:	00 
  801c81:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801c88:	e8 f3 01 00 00       	call   801e80 <_panic>
	cprintf("file_truncate is good\n");
  801c8d:	c7 04 24 15 4b 80 00 	movl   $0x804b15,(%esp)
  801c94:	e8 ac 02 00 00       	call   801f45 <cprintf>

	if ((r = file_set_size(f, strlen(msg))) < 0)
  801c99:	89 1c 24             	mov    %ebx,(%esp)
  801c9c:	e8 2f 09 00 00       	call   8025d0 <strlen>
  801ca1:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ca5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ca8:	89 04 24             	mov    %eax,(%esp)
  801cab:	e8 ca ee ff ff       	call   800b7a <file_set_size>
  801cb0:	85 c0                	test   %eax,%eax
  801cb2:	79 20                	jns    801cd4 <fs_test+0x3a0>
		panic("file_set_size 2: %e", r);
  801cb4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801cb8:	c7 44 24 08 2c 4b 80 	movl   $0x804b2c,0x8(%esp)
  801cbf:	00 
  801cc0:	c7 44 24 04 3a 00 00 	movl   $0x3a,0x4(%esp)
  801cc7:	00 
  801cc8:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801ccf:	e8 ac 01 00 00       	call   801e80 <_panic>
	assert(!(vpt[VPN(f)] & PTE_D));
  801cd4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801cd7:	89 c2                	mov    %eax,%edx
  801cd9:	c1 ea 0c             	shr    $0xc,%edx
  801cdc:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801ce3:	f6 c2 40             	test   $0x40,%dl
  801ce6:	74 24                	je     801d0c <fs_test+0x3d8>
  801ce8:	c7 44 24 0c fe 4a 80 	movl   $0x804afe,0xc(%esp)
  801cef:	00 
  801cf0:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801cf7:	00 
  801cf8:	c7 44 24 04 3b 00 00 	movl   $0x3b,0x4(%esp)
  801cff:	00 
  801d00:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801d07:	e8 74 01 00 00       	call   801e80 <_panic>
	if ((r = file_get_block(f, 0, &blk)) < 0)
  801d0c:	8d 55 f0             	lea    -0x10(%ebp),%edx
  801d0f:	89 54 24 08          	mov    %edx,0x8(%esp)
  801d13:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801d1a:	00 
  801d1b:	89 04 24             	mov    %eax,(%esp)
  801d1e:	e8 38 ef ff ff       	call   800c5b <file_get_block>
  801d23:	85 c0                	test   %eax,%eax
  801d25:	79 20                	jns    801d47 <fs_test+0x413>
		panic("file_get_block 2: %e", r);
  801d27:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801d2b:	c7 44 24 08 40 4b 80 	movl   $0x804b40,0x8(%esp)
  801d32:	00 
  801d33:	c7 44 24 04 3d 00 00 	movl   $0x3d,0x4(%esp)
  801d3a:	00 
  801d3b:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801d42:	e8 39 01 00 00       	call   801e80 <_panic>
	strcpy(blk, msg);
  801d47:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801d4b:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801d4e:	89 04 24             	mov    %eax,(%esp)
  801d51:	e8 c4 08 00 00       	call   80261a <strcpy>
	assert((vpt[VPN(blk)] & PTE_D));
  801d56:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801d59:	c1 e8 0c             	shr    $0xc,%eax
  801d5c:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801d63:	a8 40                	test   $0x40,%al
  801d65:	75 24                	jne    801d8b <fs_test+0x457>
  801d67:	c7 44 24 0c ac 4a 80 	movl   $0x804aac,0xc(%esp)
  801d6e:	00 
  801d6f:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801d76:	00 
  801d77:	c7 44 24 04 3f 00 00 	movl   $0x3f,0x4(%esp)
  801d7e:	00 
  801d7f:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801d86:	e8 f5 00 00 00       	call   801e80 <_panic>
	file_flush(f);
  801d8b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d8e:	89 04 24             	mov    %eax,(%esp)
  801d91:	e8 24 ee ff ff       	call   800bba <file_flush>
	assert(!(vpt[VPN(blk)] & PTE_D));
  801d96:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801d99:	c1 e8 0c             	shr    $0xc,%eax
  801d9c:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801da3:	a8 40                	test   $0x40,%al
  801da5:	74 24                	je     801dcb <fs_test+0x497>
  801da7:	c7 44 24 0c ab 4a 80 	movl   $0x804aab,0xc(%esp)
  801dae:	00 
  801daf:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801db6:	00 
  801db7:	c7 44 24 04 41 00 00 	movl   $0x41,0x4(%esp)
  801dbe:	00 
  801dbf:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801dc6:	e8 b5 00 00 00       	call   801e80 <_panic>
	assert(!(vpt[VPN(f)] & PTE_D));
  801dcb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801dce:	c1 e8 0c             	shr    $0xc,%eax
  801dd1:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801dd8:	a8 40                	test   $0x40,%al
  801dda:	74 24                	je     801e00 <fs_test+0x4cc>
  801ddc:	c7 44 24 0c fe 4a 80 	movl   $0x804afe,0xc(%esp)
  801de3:	00 
  801de4:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  801deb:	00 
  801dec:	c7 44 24 04 42 00 00 	movl   $0x42,0x4(%esp)
  801df3:	00 
  801df4:	c7 04 24 df 49 80 00 	movl   $0x8049df,(%esp)
  801dfb:	e8 80 00 00 00       	call   801e80 <_panic>
	cprintf("file rewrite is good\n");
  801e00:	c7 04 24 55 4b 80 00 	movl   $0x804b55,(%esp)
  801e07:	e8 39 01 00 00       	call   801f45 <cprintf>
}
  801e0c:	83 c4 24             	add    $0x24,%esp
  801e0f:	5b                   	pop    %ebx
  801e10:	5d                   	pop    %ebp
  801e11:	c3                   	ret    
	...

00801e14 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  801e14:	55                   	push   %ebp
  801e15:	89 e5                	mov    %esp,%ebp
  801e17:	83 ec 18             	sub    $0x18,%esp
  801e1a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801e1d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801e20:	8b 75 08             	mov    0x8(%ebp),%esi
  801e23:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  801e26:	e8 de 0f 00 00       	call   802e09 <sys_getenvid>
	env = &envs [ENVX(envid)];
  801e2b:	25 ff 03 00 00       	and    $0x3ff,%eax
  801e30:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801e33:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  801e38:	a3 e0 d0 80 00       	mov    %eax,0x80d0e0

	// save the name of the program so that panic() can use it
	if (argc > 0)
  801e3d:	85 f6                	test   %esi,%esi
  801e3f:	7e 07                	jle    801e48 <libmain+0x34>
		binaryname = argv[0];
  801e41:	8b 03                	mov    (%ebx),%eax
  801e43:	a3 64 d0 80 00       	mov    %eax,0x80d064

	// call user main routine
	umain(argc, argv);
  801e48:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801e4c:	89 34 24             	mov    %esi,(%esp)
  801e4f:	e8 87 fa ff ff       	call   8018db <umain>

	// exit gracefully
	exit();
  801e54:	e8 0b 00 00 00       	call   801e64 <exit>
}
  801e59:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801e5c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801e5f:	89 ec                	mov    %ebp,%esp
  801e61:	5d                   	pop    %ebp
  801e62:	c3                   	ret    
	...

00801e64 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  801e64:	55                   	push   %ebp
  801e65:	89 e5                	mov    %esp,%ebp
  801e67:	83 ec 18             	sub    $0x18,%esp
	close_all();
  801e6a:	e8 da 16 00 00       	call   803549 <close_all>
	sys_env_destroy(0);
  801e6f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e76:	e8 c2 0f 00 00       	call   802e3d <sys_env_destroy>
}
  801e7b:	c9                   	leave  
  801e7c:	c3                   	ret    
  801e7d:	00 00                	add    %al,(%eax)
	...

00801e80 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  801e80:	55                   	push   %ebp
  801e81:	89 e5                	mov    %esp,%ebp
  801e83:	53                   	push   %ebx
  801e84:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  801e87:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  801e8a:	a1 e4 d0 80 00       	mov    0x80d0e4,%eax
  801e8f:	85 c0                	test   %eax,%eax
  801e91:	74 10                	je     801ea3 <_panic+0x23>
		cprintf("%s: ", argv0);
  801e93:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e97:	c7 04 24 13 4c 80 00 	movl   $0x804c13,(%esp)
  801e9e:	e8 a2 00 00 00       	call   801f45 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  801ea3:	8b 45 0c             	mov    0xc(%ebp),%eax
  801ea6:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801eaa:	8b 45 08             	mov    0x8(%ebp),%eax
  801ead:	89 44 24 08          	mov    %eax,0x8(%esp)
  801eb1:	a1 64 d0 80 00       	mov    0x80d064,%eax
  801eb6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eba:	c7 04 24 18 4c 80 00 	movl   $0x804c18,(%esp)
  801ec1:	e8 7f 00 00 00       	call   801f45 <cprintf>
	vcprintf(fmt, ap);
  801ec6:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801eca:	8b 45 10             	mov    0x10(%ebp),%eax
  801ecd:	89 04 24             	mov    %eax,(%esp)
  801ed0:	e8 0f 00 00 00       	call   801ee4 <vcprintf>
	cprintf("\n");
  801ed5:	c7 04 24 19 48 80 00 	movl   $0x804819,(%esp)
  801edc:	e8 64 00 00 00       	call   801f45 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  801ee1:	cc                   	int3   
  801ee2:	eb fd                	jmp    801ee1 <_panic+0x61>

00801ee4 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  801ee4:	55                   	push   %ebp
  801ee5:	89 e5                	mov    %esp,%ebp
  801ee7:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  801eed:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  801ef4:	00 00 00 
	b.cnt = 0;
  801ef7:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  801efe:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  801f01:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f04:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801f08:	8b 45 08             	mov    0x8(%ebp),%eax
  801f0b:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f0f:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  801f15:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f19:	c7 04 24 5f 1f 80 00 	movl   $0x801f5f,(%esp)
  801f20:	e8 d8 01 00 00       	call   8020fd <vprintfmt>
	sys_cputs(b.buf, b.idx);
  801f25:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  801f2b:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f2f:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  801f35:	89 04 24             	mov    %eax,(%esp)
  801f38:	e8 d3 0a 00 00       	call   802a10 <sys_cputs>

	return b.cnt;
}
  801f3d:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  801f43:	c9                   	leave  
  801f44:	c3                   	ret    

00801f45 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  801f45:	55                   	push   %ebp
  801f46:	89 e5                	mov    %esp,%ebp
  801f48:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  801f4b:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  801f4e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f52:	8b 45 08             	mov    0x8(%ebp),%eax
  801f55:	89 04 24             	mov    %eax,(%esp)
  801f58:	e8 87 ff ff ff       	call   801ee4 <vcprintf>
	va_end(ap);

	return cnt;
}
  801f5d:	c9                   	leave  
  801f5e:	c3                   	ret    

00801f5f <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  801f5f:	55                   	push   %ebp
  801f60:	89 e5                	mov    %esp,%ebp
  801f62:	53                   	push   %ebx
  801f63:	83 ec 14             	sub    $0x14,%esp
  801f66:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  801f69:	8b 03                	mov    (%ebx),%eax
  801f6b:	8b 55 08             	mov    0x8(%ebp),%edx
  801f6e:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  801f72:	83 c0 01             	add    $0x1,%eax
  801f75:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  801f77:	3d ff 00 00 00       	cmp    $0xff,%eax
  801f7c:	75 19                	jne    801f97 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  801f7e:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  801f85:	00 
  801f86:	8d 43 08             	lea    0x8(%ebx),%eax
  801f89:	89 04 24             	mov    %eax,(%esp)
  801f8c:	e8 7f 0a 00 00       	call   802a10 <sys_cputs>
		b->idx = 0;
  801f91:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  801f97:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  801f9b:	83 c4 14             	add    $0x14,%esp
  801f9e:	5b                   	pop    %ebx
  801f9f:	5d                   	pop    %ebp
  801fa0:	c3                   	ret    
	...

00801fb0 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  801fb0:	55                   	push   %ebp
  801fb1:	89 e5                	mov    %esp,%ebp
  801fb3:	57                   	push   %edi
  801fb4:	56                   	push   %esi
  801fb5:	53                   	push   %ebx
  801fb6:	83 ec 4c             	sub    $0x4c,%esp
  801fb9:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801fbc:	89 d6                	mov    %edx,%esi
  801fbe:	8b 45 08             	mov    0x8(%ebp),%eax
  801fc1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  801fc4:	8b 55 0c             	mov    0xc(%ebp),%edx
  801fc7:	89 55 e0             	mov    %edx,-0x20(%ebp)
  801fca:	8b 45 10             	mov    0x10(%ebp),%eax
  801fcd:	8b 5d 14             	mov    0x14(%ebp),%ebx
  801fd0:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  801fd3:	89 45 dc             	mov    %eax,-0x24(%ebp)
  801fd6:	b9 00 00 00 00       	mov    $0x0,%ecx
  801fdb:	39 d1                	cmp    %edx,%ecx
  801fdd:	72 15                	jb     801ff4 <printnum+0x44>
  801fdf:	77 07                	ja     801fe8 <printnum+0x38>
  801fe1:	8b 55 d8             	mov    -0x28(%ebp),%edx
  801fe4:	39 d0                	cmp    %edx,%eax
  801fe6:	76 0c                	jbe    801ff4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  801fe8:	83 eb 01             	sub    $0x1,%ebx
  801feb:	85 db                	test   %ebx,%ebx
  801fed:	8d 76 00             	lea    0x0(%esi),%esi
  801ff0:	7f 61                	jg     802053 <printnum+0xa3>
  801ff2:	eb 70                	jmp    802064 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  801ff4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  801ff8:	83 eb 01             	sub    $0x1,%ebx
  801ffb:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801fff:	89 44 24 08          	mov    %eax,0x8(%esp)
  802003:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  802007:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80200b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80200e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  802011:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  802014:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802018:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80201f:	00 
  802020:	8b 45 d8             	mov    -0x28(%ebp),%eax
  802023:	89 04 24             	mov    %eax,(%esp)
  802026:	8b 55 e0             	mov    -0x20(%ebp),%edx
  802029:	89 54 24 04          	mov    %edx,0x4(%esp)
  80202d:	e8 be 23 00 00       	call   8043f0 <__udivdi3>
  802032:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  802035:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  802038:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80203c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  802040:	89 04 24             	mov    %eax,(%esp)
  802043:	89 54 24 04          	mov    %edx,0x4(%esp)
  802047:	89 f2                	mov    %esi,%edx
  802049:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80204c:	e8 5f ff ff ff       	call   801fb0 <printnum>
  802051:	eb 11                	jmp    802064 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  802053:	89 74 24 04          	mov    %esi,0x4(%esp)
  802057:	89 3c 24             	mov    %edi,(%esp)
  80205a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80205d:	83 eb 01             	sub    $0x1,%ebx
  802060:	85 db                	test   %ebx,%ebx
  802062:	7f ef                	jg     802053 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  802064:	89 74 24 04          	mov    %esi,0x4(%esp)
  802068:	8b 74 24 04          	mov    0x4(%esp),%esi
  80206c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80206f:	89 44 24 08          	mov    %eax,0x8(%esp)
  802073:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80207a:	00 
  80207b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80207e:	89 14 24             	mov    %edx,(%esp)
  802081:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  802084:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  802088:	e8 93 24 00 00       	call   804520 <__umoddi3>
  80208d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802091:	0f be 80 34 4c 80 00 	movsbl 0x804c34(%eax),%eax
  802098:	89 04 24             	mov    %eax,(%esp)
  80209b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80209e:	83 c4 4c             	add    $0x4c,%esp
  8020a1:	5b                   	pop    %ebx
  8020a2:	5e                   	pop    %esi
  8020a3:	5f                   	pop    %edi
  8020a4:	5d                   	pop    %ebp
  8020a5:	c3                   	ret    

008020a6 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  8020a6:	55                   	push   %ebp
  8020a7:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  8020a9:	83 fa 01             	cmp    $0x1,%edx
  8020ac:	7e 0e                	jle    8020bc <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  8020ae:	8b 10                	mov    (%eax),%edx
  8020b0:	8d 4a 08             	lea    0x8(%edx),%ecx
  8020b3:	89 08                	mov    %ecx,(%eax)
  8020b5:	8b 02                	mov    (%edx),%eax
  8020b7:	8b 52 04             	mov    0x4(%edx),%edx
  8020ba:	eb 22                	jmp    8020de <getuint+0x38>
	else if (lflag)
  8020bc:	85 d2                	test   %edx,%edx
  8020be:	74 10                	je     8020d0 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  8020c0:	8b 10                	mov    (%eax),%edx
  8020c2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8020c5:	89 08                	mov    %ecx,(%eax)
  8020c7:	8b 02                	mov    (%edx),%eax
  8020c9:	ba 00 00 00 00       	mov    $0x0,%edx
  8020ce:	eb 0e                	jmp    8020de <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  8020d0:	8b 10                	mov    (%eax),%edx
  8020d2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8020d5:	89 08                	mov    %ecx,(%eax)
  8020d7:	8b 02                	mov    (%edx),%eax
  8020d9:	ba 00 00 00 00       	mov    $0x0,%edx
}
  8020de:	5d                   	pop    %ebp
  8020df:	c3                   	ret    

008020e0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8020e0:	55                   	push   %ebp
  8020e1:	89 e5                	mov    %esp,%ebp
  8020e3:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8020e6:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8020ea:	8b 10                	mov    (%eax),%edx
  8020ec:	3b 50 04             	cmp    0x4(%eax),%edx
  8020ef:	73 0a                	jae    8020fb <sprintputch+0x1b>
		*b->buf++ = ch;
  8020f1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8020f4:	88 0a                	mov    %cl,(%edx)
  8020f6:	83 c2 01             	add    $0x1,%edx
  8020f9:	89 10                	mov    %edx,(%eax)
}
  8020fb:	5d                   	pop    %ebp
  8020fc:	c3                   	ret    

008020fd <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8020fd:	55                   	push   %ebp
  8020fe:	89 e5                	mov    %esp,%ebp
  802100:	57                   	push   %edi
  802101:	56                   	push   %esi
  802102:	53                   	push   %ebx
  802103:	83 ec 5c             	sub    $0x5c,%esp
  802106:	8b 7d 08             	mov    0x8(%ebp),%edi
  802109:	8b 75 0c             	mov    0xc(%ebp),%esi
  80210c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80210f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  802116:	eb 11                	jmp    802129 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  802118:	85 c0                	test   %eax,%eax
  80211a:	0f 84 f9 03 00 00    	je     802519 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  802120:	89 74 24 04          	mov    %esi,0x4(%esp)
  802124:	89 04 24             	mov    %eax,(%esp)
  802127:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  802129:	0f b6 03             	movzbl (%ebx),%eax
  80212c:	83 c3 01             	add    $0x1,%ebx
  80212f:	83 f8 25             	cmp    $0x25,%eax
  802132:	75 e4                	jne    802118 <vprintfmt+0x1b>
  802134:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  802138:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80213f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  802146:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80214d:	b9 00 00 00 00       	mov    $0x0,%ecx
  802152:	eb 06                	jmp    80215a <vprintfmt+0x5d>
  802154:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  802158:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80215a:	0f b6 13             	movzbl (%ebx),%edx
  80215d:	0f b6 c2             	movzbl %dl,%eax
  802160:	89 45 e0             	mov    %eax,-0x20(%ebp)
  802163:	8d 43 01             	lea    0x1(%ebx),%eax
  802166:	83 ea 23             	sub    $0x23,%edx
  802169:	80 fa 55             	cmp    $0x55,%dl
  80216c:	0f 87 8a 03 00 00    	ja     8024fc <vprintfmt+0x3ff>
  802172:	0f b6 d2             	movzbl %dl,%edx
  802175:	ff 24 95 80 4d 80 00 	jmp    *0x804d80(,%edx,4)
  80217c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  802180:	eb d6                	jmp    802158 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  802182:	8b 55 e0             	mov    -0x20(%ebp),%edx
  802185:	83 ea 30             	sub    $0x30,%edx
  802188:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80218b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80218e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  802191:	83 fb 09             	cmp    $0x9,%ebx
  802194:	77 54                	ja     8021ea <vprintfmt+0xed>
  802196:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  802199:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80219c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80219f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  8021a2:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  8021a6:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8021a9:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8021ac:	83 fb 09             	cmp    $0x9,%ebx
  8021af:	76 eb                	jbe    80219c <vprintfmt+0x9f>
  8021b1:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8021b4:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8021b7:	eb 31                	jmp    8021ea <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  8021b9:	8b 55 14             	mov    0x14(%ebp),%edx
  8021bc:	8d 5a 04             	lea    0x4(%edx),%ebx
  8021bf:	89 5d 14             	mov    %ebx,0x14(%ebp)
  8021c2:	8b 12                	mov    (%edx),%edx
  8021c4:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  8021c7:	eb 21                	jmp    8021ea <vprintfmt+0xed>

		case '.':
			if (width < 0)
  8021c9:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8021cd:	ba 00 00 00 00       	mov    $0x0,%edx
  8021d2:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  8021d6:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8021d9:	e9 7a ff ff ff       	jmp    802158 <vprintfmt+0x5b>
  8021de:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  8021e5:	e9 6e ff ff ff       	jmp    802158 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  8021ea:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8021ee:	0f 89 64 ff ff ff    	jns    802158 <vprintfmt+0x5b>
  8021f4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8021f7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8021fa:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8021fd:	89 55 d0             	mov    %edx,-0x30(%ebp)
  802200:	e9 53 ff ff ff       	jmp    802158 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  802205:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  802208:	e9 4b ff ff ff       	jmp    802158 <vprintfmt+0x5b>
  80220d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  802210:	8b 45 14             	mov    0x14(%ebp),%eax
  802213:	8d 50 04             	lea    0x4(%eax),%edx
  802216:	89 55 14             	mov    %edx,0x14(%ebp)
  802219:	89 74 24 04          	mov    %esi,0x4(%esp)
  80221d:	8b 00                	mov    (%eax),%eax
  80221f:	89 04 24             	mov    %eax,(%esp)
  802222:	ff d7                	call   *%edi
  802224:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  802227:	e9 fd fe ff ff       	jmp    802129 <vprintfmt+0x2c>
  80222c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80222f:	8b 45 14             	mov    0x14(%ebp),%eax
  802232:	8d 50 04             	lea    0x4(%eax),%edx
  802235:	89 55 14             	mov    %edx,0x14(%ebp)
  802238:	8b 00                	mov    (%eax),%eax
  80223a:	89 c2                	mov    %eax,%edx
  80223c:	c1 fa 1f             	sar    $0x1f,%edx
  80223f:	31 d0                	xor    %edx,%eax
  802241:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  802243:	83 f8 12             	cmp    $0x12,%eax
  802246:	7f 0b                	jg     802253 <vprintfmt+0x156>
  802248:	8b 14 85 e0 4e 80 00 	mov    0x804ee0(,%eax,4),%edx
  80224f:	85 d2                	test   %edx,%edx
  802251:	75 20                	jne    802273 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  802253:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802257:	c7 44 24 08 45 4c 80 	movl   $0x804c45,0x8(%esp)
  80225e:	00 
  80225f:	89 74 24 04          	mov    %esi,0x4(%esp)
  802263:	89 3c 24             	mov    %edi,(%esp)
  802266:	e8 36 03 00 00       	call   8025a1 <printfmt>
  80226b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80226e:	e9 b6 fe ff ff       	jmp    802129 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  802273:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802277:	c7 44 24 08 7f 46 80 	movl   $0x80467f,0x8(%esp)
  80227e:	00 
  80227f:	89 74 24 04          	mov    %esi,0x4(%esp)
  802283:	89 3c 24             	mov    %edi,(%esp)
  802286:	e8 16 03 00 00       	call   8025a1 <printfmt>
  80228b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80228e:	e9 96 fe ff ff       	jmp    802129 <vprintfmt+0x2c>
  802293:	89 45 cc             	mov    %eax,-0x34(%ebp)
  802296:	89 c3                	mov    %eax,%ebx
  802298:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80229b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80229e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  8022a1:	8b 45 14             	mov    0x14(%ebp),%eax
  8022a4:	8d 50 04             	lea    0x4(%eax),%edx
  8022a7:	89 55 14             	mov    %edx,0x14(%ebp)
  8022aa:	8b 00                	mov    (%eax),%eax
  8022ac:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8022af:	85 c0                	test   %eax,%eax
  8022b1:	b8 4e 4c 80 00       	mov    $0x804c4e,%eax
  8022b6:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  8022ba:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  8022bd:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  8022c1:	7e 06                	jle    8022c9 <vprintfmt+0x1cc>
  8022c3:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  8022c7:	75 13                	jne    8022dc <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8022c9:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8022cc:	0f be 02             	movsbl (%edx),%eax
  8022cf:	85 c0                	test   %eax,%eax
  8022d1:	0f 85 9b 00 00 00    	jne    802372 <vprintfmt+0x275>
  8022d7:	e9 88 00 00 00       	jmp    802364 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8022dc:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8022e0:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8022e3:	89 0c 24             	mov    %ecx,(%esp)
  8022e6:	e8 00 03 00 00       	call   8025eb <strnlen>
  8022eb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8022ee:	29 c2                	sub    %eax,%edx
  8022f0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8022f3:	85 d2                	test   %edx,%edx
  8022f5:	7e d2                	jle    8022c9 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8022f7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8022fb:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8022fe:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  802301:	89 d3                	mov    %edx,%ebx
  802303:	89 74 24 04          	mov    %esi,0x4(%esp)
  802307:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80230a:	89 04 24             	mov    %eax,(%esp)
  80230d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80230f:	83 eb 01             	sub    $0x1,%ebx
  802312:	85 db                	test   %ebx,%ebx
  802314:	7f ed                	jg     802303 <vprintfmt+0x206>
  802316:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  802319:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  802320:	eb a7                	jmp    8022c9 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  802322:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  802326:	74 1a                	je     802342 <vprintfmt+0x245>
  802328:	8d 50 e0             	lea    -0x20(%eax),%edx
  80232b:	83 fa 5e             	cmp    $0x5e,%edx
  80232e:	76 12                	jbe    802342 <vprintfmt+0x245>
					putch('?', putdat);
  802330:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802334:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80233b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80233e:	66 90                	xchg   %ax,%ax
  802340:	eb 0a                	jmp    80234c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  802342:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802346:	89 04 24             	mov    %eax,(%esp)
  802349:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80234c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  802350:	0f be 03             	movsbl (%ebx),%eax
  802353:	85 c0                	test   %eax,%eax
  802355:	74 05                	je     80235c <vprintfmt+0x25f>
  802357:	83 c3 01             	add    $0x1,%ebx
  80235a:	eb 29                	jmp    802385 <vprintfmt+0x288>
  80235c:	89 fe                	mov    %edi,%esi
  80235e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  802361:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  802364:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  802368:	7f 2e                	jg     802398 <vprintfmt+0x29b>
  80236a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80236d:	e9 b7 fd ff ff       	jmp    802129 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  802372:	8b 55 e0             	mov    -0x20(%ebp),%edx
  802375:	83 c2 01             	add    $0x1,%edx
  802378:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80237b:	89 f7                	mov    %esi,%edi
  80237d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  802380:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  802383:	89 d3                	mov    %edx,%ebx
  802385:	85 f6                	test   %esi,%esi
  802387:	78 99                	js     802322 <vprintfmt+0x225>
  802389:	83 ee 01             	sub    $0x1,%esi
  80238c:	79 94                	jns    802322 <vprintfmt+0x225>
  80238e:	89 fe                	mov    %edi,%esi
  802390:	8b 7d e0             	mov    -0x20(%ebp),%edi
  802393:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  802396:	eb cc                	jmp    802364 <vprintfmt+0x267>
  802398:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80239b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80239e:	89 74 24 04          	mov    %esi,0x4(%esp)
  8023a2:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  8023a9:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8023ab:	83 eb 01             	sub    $0x1,%ebx
  8023ae:	85 db                	test   %ebx,%ebx
  8023b0:	7f ec                	jg     80239e <vprintfmt+0x2a1>
  8023b2:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  8023b5:	e9 6f fd ff ff       	jmp    802129 <vprintfmt+0x2c>
  8023ba:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  8023bd:	83 f9 01             	cmp    $0x1,%ecx
  8023c0:	7e 16                	jle    8023d8 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  8023c2:	8b 45 14             	mov    0x14(%ebp),%eax
  8023c5:	8d 50 08             	lea    0x8(%eax),%edx
  8023c8:	89 55 14             	mov    %edx,0x14(%ebp)
  8023cb:	8b 10                	mov    (%eax),%edx
  8023cd:	8b 48 04             	mov    0x4(%eax),%ecx
  8023d0:	89 55 d8             	mov    %edx,-0x28(%ebp)
  8023d3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8023d6:	eb 32                	jmp    80240a <vprintfmt+0x30d>
	else if (lflag)
  8023d8:	85 c9                	test   %ecx,%ecx
  8023da:	74 18                	je     8023f4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  8023dc:	8b 45 14             	mov    0x14(%ebp),%eax
  8023df:	8d 50 04             	lea    0x4(%eax),%edx
  8023e2:	89 55 14             	mov    %edx,0x14(%ebp)
  8023e5:	8b 00                	mov    (%eax),%eax
  8023e7:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8023ea:	89 c1                	mov    %eax,%ecx
  8023ec:	c1 f9 1f             	sar    $0x1f,%ecx
  8023ef:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8023f2:	eb 16                	jmp    80240a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8023f4:	8b 45 14             	mov    0x14(%ebp),%eax
  8023f7:	8d 50 04             	lea    0x4(%eax),%edx
  8023fa:	89 55 14             	mov    %edx,0x14(%ebp)
  8023fd:	8b 00                	mov    (%eax),%eax
  8023ff:	89 45 d8             	mov    %eax,-0x28(%ebp)
  802402:	89 c2                	mov    %eax,%edx
  802404:	c1 fa 1f             	sar    $0x1f,%edx
  802407:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80240a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80240d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  802410:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  802415:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  802419:	0f 89 9b 00 00 00    	jns    8024ba <vprintfmt+0x3bd>
				putch('-', putdat);
  80241f:	89 74 24 04          	mov    %esi,0x4(%esp)
  802423:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  80242a:	ff d7                	call   *%edi
				num = -(long long) num;
  80242c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80242f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  802432:	f7 d9                	neg    %ecx
  802434:	83 d3 00             	adc    $0x0,%ebx
  802437:	f7 db                	neg    %ebx
  802439:	b8 0a 00 00 00       	mov    $0xa,%eax
  80243e:	eb 7a                	jmp    8024ba <vprintfmt+0x3bd>
  802440:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  802443:	89 ca                	mov    %ecx,%edx
  802445:	8d 45 14             	lea    0x14(%ebp),%eax
  802448:	e8 59 fc ff ff       	call   8020a6 <getuint>
  80244d:	89 c1                	mov    %eax,%ecx
  80244f:	89 d3                	mov    %edx,%ebx
  802451:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  802456:	eb 62                	jmp    8024ba <vprintfmt+0x3bd>
  802458:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80245b:	89 ca                	mov    %ecx,%edx
  80245d:	8d 45 14             	lea    0x14(%ebp),%eax
  802460:	e8 41 fc ff ff       	call   8020a6 <getuint>
  802465:	89 c1                	mov    %eax,%ecx
  802467:	89 d3                	mov    %edx,%ebx
  802469:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  80246e:	eb 4a                	jmp    8024ba <vprintfmt+0x3bd>
  802470:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  802473:	89 74 24 04          	mov    %esi,0x4(%esp)
  802477:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  80247e:	ff d7                	call   *%edi
			putch('x', putdat);
  802480:	89 74 24 04          	mov    %esi,0x4(%esp)
  802484:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80248b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80248d:	8b 45 14             	mov    0x14(%ebp),%eax
  802490:	8d 50 04             	lea    0x4(%eax),%edx
  802493:	89 55 14             	mov    %edx,0x14(%ebp)
  802496:	8b 08                	mov    (%eax),%ecx
  802498:	bb 00 00 00 00       	mov    $0x0,%ebx
  80249d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  8024a2:	eb 16                	jmp    8024ba <vprintfmt+0x3bd>
  8024a4:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  8024a7:	89 ca                	mov    %ecx,%edx
  8024a9:	8d 45 14             	lea    0x14(%ebp),%eax
  8024ac:	e8 f5 fb ff ff       	call   8020a6 <getuint>
  8024b1:	89 c1                	mov    %eax,%ecx
  8024b3:	89 d3                	mov    %edx,%ebx
  8024b5:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  8024ba:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  8024be:	89 54 24 10          	mov    %edx,0x10(%esp)
  8024c2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8024c5:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8024c9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024cd:	89 0c 24             	mov    %ecx,(%esp)
  8024d0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8024d4:	89 f2                	mov    %esi,%edx
  8024d6:	89 f8                	mov    %edi,%eax
  8024d8:	e8 d3 fa ff ff       	call   801fb0 <printnum>
  8024dd:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8024e0:	e9 44 fc ff ff       	jmp    802129 <vprintfmt+0x2c>
  8024e5:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8024e8:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  8024eb:	89 74 24 04          	mov    %esi,0x4(%esp)
  8024ef:	89 14 24             	mov    %edx,(%esp)
  8024f2:	ff d7                	call   *%edi
  8024f4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8024f7:	e9 2d fc ff ff       	jmp    802129 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  8024fc:	89 74 24 04          	mov    %esi,0x4(%esp)
  802500:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  802507:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  802509:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80250c:	80 38 25             	cmpb   $0x25,(%eax)
  80250f:	0f 84 14 fc ff ff    	je     802129 <vprintfmt+0x2c>
  802515:	89 c3                	mov    %eax,%ebx
  802517:	eb f0                	jmp    802509 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  802519:	83 c4 5c             	add    $0x5c,%esp
  80251c:	5b                   	pop    %ebx
  80251d:	5e                   	pop    %esi
  80251e:	5f                   	pop    %edi
  80251f:	5d                   	pop    %ebp
  802520:	c3                   	ret    

00802521 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  802521:	55                   	push   %ebp
  802522:	89 e5                	mov    %esp,%ebp
  802524:	83 ec 28             	sub    $0x28,%esp
  802527:	8b 45 08             	mov    0x8(%ebp),%eax
  80252a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  80252d:	85 c0                	test   %eax,%eax
  80252f:	74 04                	je     802535 <vsnprintf+0x14>
  802531:	85 d2                	test   %edx,%edx
  802533:	7f 07                	jg     80253c <vsnprintf+0x1b>
  802535:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80253a:	eb 3b                	jmp    802577 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  80253c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  80253f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  802543:	89 45 f0             	mov    %eax,-0x10(%ebp)
  802546:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  80254d:	8b 45 14             	mov    0x14(%ebp),%eax
  802550:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802554:	8b 45 10             	mov    0x10(%ebp),%eax
  802557:	89 44 24 08          	mov    %eax,0x8(%esp)
  80255b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  80255e:	89 44 24 04          	mov    %eax,0x4(%esp)
  802562:	c7 04 24 e0 20 80 00 	movl   $0x8020e0,(%esp)
  802569:	e8 8f fb ff ff       	call   8020fd <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  80256e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  802571:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  802574:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  802577:	c9                   	leave  
  802578:	c3                   	ret    

00802579 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  802579:	55                   	push   %ebp
  80257a:	89 e5                	mov    %esp,%ebp
  80257c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  80257f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  802582:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802586:	8b 45 10             	mov    0x10(%ebp),%eax
  802589:	89 44 24 08          	mov    %eax,0x8(%esp)
  80258d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802590:	89 44 24 04          	mov    %eax,0x4(%esp)
  802594:	8b 45 08             	mov    0x8(%ebp),%eax
  802597:	89 04 24             	mov    %eax,(%esp)
  80259a:	e8 82 ff ff ff       	call   802521 <vsnprintf>
	va_end(ap);

	return rc;
}
  80259f:	c9                   	leave  
  8025a0:	c3                   	ret    

008025a1 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  8025a1:	55                   	push   %ebp
  8025a2:	89 e5                	mov    %esp,%ebp
  8025a4:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  8025a7:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  8025aa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8025ae:	8b 45 10             	mov    0x10(%ebp),%eax
  8025b1:	89 44 24 08          	mov    %eax,0x8(%esp)
  8025b5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025b8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025bc:	8b 45 08             	mov    0x8(%ebp),%eax
  8025bf:	89 04 24             	mov    %eax,(%esp)
  8025c2:	e8 36 fb ff ff       	call   8020fd <vprintfmt>
	va_end(ap);
}
  8025c7:	c9                   	leave  
  8025c8:	c3                   	ret    
  8025c9:	00 00                	add    %al,(%eax)
  8025cb:	00 00                	add    %al,(%eax)
  8025cd:	00 00                	add    %al,(%eax)
	...

008025d0 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  8025d0:	55                   	push   %ebp
  8025d1:	89 e5                	mov    %esp,%ebp
  8025d3:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  8025d6:	b8 00 00 00 00       	mov    $0x0,%eax
  8025db:	80 3a 00             	cmpb   $0x0,(%edx)
  8025de:	74 09                	je     8025e9 <strlen+0x19>
		n++;
  8025e0:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  8025e3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  8025e7:	75 f7                	jne    8025e0 <strlen+0x10>
		n++;
	return n;
}
  8025e9:	5d                   	pop    %ebp
  8025ea:	c3                   	ret    

008025eb <strnlen>:

int
strnlen(const char *s, size_t size)
{
  8025eb:	55                   	push   %ebp
  8025ec:	89 e5                	mov    %esp,%ebp
  8025ee:	53                   	push   %ebx
  8025ef:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8025f2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8025f5:	85 c9                	test   %ecx,%ecx
  8025f7:	74 19                	je     802612 <strnlen+0x27>
  8025f9:	80 3b 00             	cmpb   $0x0,(%ebx)
  8025fc:	74 14                	je     802612 <strnlen+0x27>
  8025fe:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  802603:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  802606:	39 c8                	cmp    %ecx,%eax
  802608:	74 0d                	je     802617 <strnlen+0x2c>
  80260a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  80260e:	75 f3                	jne    802603 <strnlen+0x18>
  802610:	eb 05                	jmp    802617 <strnlen+0x2c>
  802612:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  802617:	5b                   	pop    %ebx
  802618:	5d                   	pop    %ebp
  802619:	c3                   	ret    

0080261a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80261a:	55                   	push   %ebp
  80261b:	89 e5                	mov    %esp,%ebp
  80261d:	53                   	push   %ebx
  80261e:	8b 45 08             	mov    0x8(%ebp),%eax
  802621:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  802624:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  802629:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  80262d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  802630:	83 c2 01             	add    $0x1,%edx
  802633:	84 c9                	test   %cl,%cl
  802635:	75 f2                	jne    802629 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  802637:	5b                   	pop    %ebx
  802638:	5d                   	pop    %ebp
  802639:	c3                   	ret    

0080263a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  80263a:	55                   	push   %ebp
  80263b:	89 e5                	mov    %esp,%ebp
  80263d:	56                   	push   %esi
  80263e:	53                   	push   %ebx
  80263f:	8b 45 08             	mov    0x8(%ebp),%eax
  802642:	8b 55 0c             	mov    0xc(%ebp),%edx
  802645:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  802648:	85 f6                	test   %esi,%esi
  80264a:	74 18                	je     802664 <strncpy+0x2a>
  80264c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  802651:	0f b6 1a             	movzbl (%edx),%ebx
  802654:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  802657:	80 3a 01             	cmpb   $0x1,(%edx)
  80265a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  80265d:	83 c1 01             	add    $0x1,%ecx
  802660:	39 ce                	cmp    %ecx,%esi
  802662:	77 ed                	ja     802651 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  802664:	5b                   	pop    %ebx
  802665:	5e                   	pop    %esi
  802666:	5d                   	pop    %ebp
  802667:	c3                   	ret    

00802668 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  802668:	55                   	push   %ebp
  802669:	89 e5                	mov    %esp,%ebp
  80266b:	56                   	push   %esi
  80266c:	53                   	push   %ebx
  80266d:	8b 75 08             	mov    0x8(%ebp),%esi
  802670:	8b 55 0c             	mov    0xc(%ebp),%edx
  802673:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  802676:	89 f0                	mov    %esi,%eax
  802678:	85 c9                	test   %ecx,%ecx
  80267a:	74 27                	je     8026a3 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  80267c:	83 e9 01             	sub    $0x1,%ecx
  80267f:	74 1d                	je     80269e <strlcpy+0x36>
  802681:	0f b6 1a             	movzbl (%edx),%ebx
  802684:	84 db                	test   %bl,%bl
  802686:	74 16                	je     80269e <strlcpy+0x36>
			*dst++ = *src++;
  802688:	88 18                	mov    %bl,(%eax)
  80268a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  80268d:	83 e9 01             	sub    $0x1,%ecx
  802690:	74 0e                	je     8026a0 <strlcpy+0x38>
			*dst++ = *src++;
  802692:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  802695:	0f b6 1a             	movzbl (%edx),%ebx
  802698:	84 db                	test   %bl,%bl
  80269a:	75 ec                	jne    802688 <strlcpy+0x20>
  80269c:	eb 02                	jmp    8026a0 <strlcpy+0x38>
  80269e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  8026a0:	c6 00 00             	movb   $0x0,(%eax)
  8026a3:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  8026a5:	5b                   	pop    %ebx
  8026a6:	5e                   	pop    %esi
  8026a7:	5d                   	pop    %ebp
  8026a8:	c3                   	ret    

008026a9 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  8026a9:	55                   	push   %ebp
  8026aa:	89 e5                	mov    %esp,%ebp
  8026ac:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8026af:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  8026b2:	0f b6 01             	movzbl (%ecx),%eax
  8026b5:	84 c0                	test   %al,%al
  8026b7:	74 15                	je     8026ce <strcmp+0x25>
  8026b9:	3a 02                	cmp    (%edx),%al
  8026bb:	75 11                	jne    8026ce <strcmp+0x25>
		p++, q++;
  8026bd:	83 c1 01             	add    $0x1,%ecx
  8026c0:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  8026c3:	0f b6 01             	movzbl (%ecx),%eax
  8026c6:	84 c0                	test   %al,%al
  8026c8:	74 04                	je     8026ce <strcmp+0x25>
  8026ca:	3a 02                	cmp    (%edx),%al
  8026cc:	74 ef                	je     8026bd <strcmp+0x14>
  8026ce:	0f b6 c0             	movzbl %al,%eax
  8026d1:	0f b6 12             	movzbl (%edx),%edx
  8026d4:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  8026d6:	5d                   	pop    %ebp
  8026d7:	c3                   	ret    

008026d8 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  8026d8:	55                   	push   %ebp
  8026d9:	89 e5                	mov    %esp,%ebp
  8026db:	53                   	push   %ebx
  8026dc:	8b 55 08             	mov    0x8(%ebp),%edx
  8026df:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8026e2:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  8026e5:	85 c0                	test   %eax,%eax
  8026e7:	74 23                	je     80270c <strncmp+0x34>
  8026e9:	0f b6 1a             	movzbl (%edx),%ebx
  8026ec:	84 db                	test   %bl,%bl
  8026ee:	74 24                	je     802714 <strncmp+0x3c>
  8026f0:	3a 19                	cmp    (%ecx),%bl
  8026f2:	75 20                	jne    802714 <strncmp+0x3c>
  8026f4:	83 e8 01             	sub    $0x1,%eax
  8026f7:	74 13                	je     80270c <strncmp+0x34>
		n--, p++, q++;
  8026f9:	83 c2 01             	add    $0x1,%edx
  8026fc:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  8026ff:	0f b6 1a             	movzbl (%edx),%ebx
  802702:	84 db                	test   %bl,%bl
  802704:	74 0e                	je     802714 <strncmp+0x3c>
  802706:	3a 19                	cmp    (%ecx),%bl
  802708:	74 ea                	je     8026f4 <strncmp+0x1c>
  80270a:	eb 08                	jmp    802714 <strncmp+0x3c>
  80270c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  802711:	5b                   	pop    %ebx
  802712:	5d                   	pop    %ebp
  802713:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  802714:	0f b6 02             	movzbl (%edx),%eax
  802717:	0f b6 11             	movzbl (%ecx),%edx
  80271a:	29 d0                	sub    %edx,%eax
  80271c:	eb f3                	jmp    802711 <strncmp+0x39>

0080271e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  80271e:	55                   	push   %ebp
  80271f:	89 e5                	mov    %esp,%ebp
  802721:	8b 45 08             	mov    0x8(%ebp),%eax
  802724:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  802728:	0f b6 10             	movzbl (%eax),%edx
  80272b:	84 d2                	test   %dl,%dl
  80272d:	74 15                	je     802744 <strchr+0x26>
		if (*s == c)
  80272f:	38 ca                	cmp    %cl,%dl
  802731:	75 07                	jne    80273a <strchr+0x1c>
  802733:	eb 14                	jmp    802749 <strchr+0x2b>
  802735:	38 ca                	cmp    %cl,%dl
  802737:	90                   	nop
  802738:	74 0f                	je     802749 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  80273a:	83 c0 01             	add    $0x1,%eax
  80273d:	0f b6 10             	movzbl (%eax),%edx
  802740:	84 d2                	test   %dl,%dl
  802742:	75 f1                	jne    802735 <strchr+0x17>
  802744:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  802749:	5d                   	pop    %ebp
  80274a:	c3                   	ret    

0080274b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  80274b:	55                   	push   %ebp
  80274c:	89 e5                	mov    %esp,%ebp
  80274e:	8b 45 08             	mov    0x8(%ebp),%eax
  802751:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  802755:	0f b6 10             	movzbl (%eax),%edx
  802758:	84 d2                	test   %dl,%dl
  80275a:	74 18                	je     802774 <strfind+0x29>
		if (*s == c)
  80275c:	38 ca                	cmp    %cl,%dl
  80275e:	75 0a                	jne    80276a <strfind+0x1f>
  802760:	eb 12                	jmp    802774 <strfind+0x29>
  802762:	38 ca                	cmp    %cl,%dl
  802764:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802768:	74 0a                	je     802774 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  80276a:	83 c0 01             	add    $0x1,%eax
  80276d:	0f b6 10             	movzbl (%eax),%edx
  802770:	84 d2                	test   %dl,%dl
  802772:	75 ee                	jne    802762 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  802774:	5d                   	pop    %ebp
  802775:	c3                   	ret    

00802776 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  802776:	55                   	push   %ebp
  802777:	89 e5                	mov    %esp,%ebp
  802779:	83 ec 0c             	sub    $0xc,%esp
  80277c:	89 1c 24             	mov    %ebx,(%esp)
  80277f:	89 74 24 04          	mov    %esi,0x4(%esp)
  802783:	89 7c 24 08          	mov    %edi,0x8(%esp)
  802787:	8b 7d 08             	mov    0x8(%ebp),%edi
  80278a:	8b 45 0c             	mov    0xc(%ebp),%eax
  80278d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  802790:	85 c9                	test   %ecx,%ecx
  802792:	74 30                	je     8027c4 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  802794:	f7 c7 03 00 00 00    	test   $0x3,%edi
  80279a:	75 25                	jne    8027c1 <memset+0x4b>
  80279c:	f6 c1 03             	test   $0x3,%cl
  80279f:	75 20                	jne    8027c1 <memset+0x4b>
		c &= 0xFF;
  8027a1:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  8027a4:	89 d3                	mov    %edx,%ebx
  8027a6:	c1 e3 08             	shl    $0x8,%ebx
  8027a9:	89 d6                	mov    %edx,%esi
  8027ab:	c1 e6 18             	shl    $0x18,%esi
  8027ae:	89 d0                	mov    %edx,%eax
  8027b0:	c1 e0 10             	shl    $0x10,%eax
  8027b3:	09 f0                	or     %esi,%eax
  8027b5:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  8027b7:	09 d8                	or     %ebx,%eax
  8027b9:	c1 e9 02             	shr    $0x2,%ecx
  8027bc:	fc                   	cld    
  8027bd:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  8027bf:	eb 03                	jmp    8027c4 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  8027c1:	fc                   	cld    
  8027c2:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  8027c4:	89 f8                	mov    %edi,%eax
  8027c6:	8b 1c 24             	mov    (%esp),%ebx
  8027c9:	8b 74 24 04          	mov    0x4(%esp),%esi
  8027cd:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8027d1:	89 ec                	mov    %ebp,%esp
  8027d3:	5d                   	pop    %ebp
  8027d4:	c3                   	ret    

008027d5 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  8027d5:	55                   	push   %ebp
  8027d6:	89 e5                	mov    %esp,%ebp
  8027d8:	83 ec 08             	sub    $0x8,%esp
  8027db:	89 34 24             	mov    %esi,(%esp)
  8027de:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8027e2:	8b 45 08             	mov    0x8(%ebp),%eax
  8027e5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  8027e8:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  8027eb:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  8027ed:	39 c6                	cmp    %eax,%esi
  8027ef:	73 35                	jae    802826 <memmove+0x51>
  8027f1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  8027f4:	39 d0                	cmp    %edx,%eax
  8027f6:	73 2e                	jae    802826 <memmove+0x51>
		s += n;
		d += n;
  8027f8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  8027fa:	f6 c2 03             	test   $0x3,%dl
  8027fd:	75 1b                	jne    80281a <memmove+0x45>
  8027ff:	f7 c7 03 00 00 00    	test   $0x3,%edi
  802805:	75 13                	jne    80281a <memmove+0x45>
  802807:	f6 c1 03             	test   $0x3,%cl
  80280a:	75 0e                	jne    80281a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  80280c:	83 ef 04             	sub    $0x4,%edi
  80280f:	8d 72 fc             	lea    -0x4(%edx),%esi
  802812:	c1 e9 02             	shr    $0x2,%ecx
  802815:	fd                   	std    
  802816:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  802818:	eb 09                	jmp    802823 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  80281a:	83 ef 01             	sub    $0x1,%edi
  80281d:	8d 72 ff             	lea    -0x1(%edx),%esi
  802820:	fd                   	std    
  802821:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  802823:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  802824:	eb 20                	jmp    802846 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  802826:	f7 c6 03 00 00 00    	test   $0x3,%esi
  80282c:	75 15                	jne    802843 <memmove+0x6e>
  80282e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  802834:	75 0d                	jne    802843 <memmove+0x6e>
  802836:	f6 c1 03             	test   $0x3,%cl
  802839:	75 08                	jne    802843 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  80283b:	c1 e9 02             	shr    $0x2,%ecx
  80283e:	fc                   	cld    
  80283f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  802841:	eb 03                	jmp    802846 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  802843:	fc                   	cld    
  802844:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  802846:	8b 34 24             	mov    (%esp),%esi
  802849:	8b 7c 24 04          	mov    0x4(%esp),%edi
  80284d:	89 ec                	mov    %ebp,%esp
  80284f:	5d                   	pop    %ebp
  802850:	c3                   	ret    

00802851 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  802851:	55                   	push   %ebp
  802852:	89 e5                	mov    %esp,%ebp
  802854:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  802857:	8b 45 10             	mov    0x10(%ebp),%eax
  80285a:	89 44 24 08          	mov    %eax,0x8(%esp)
  80285e:	8b 45 0c             	mov    0xc(%ebp),%eax
  802861:	89 44 24 04          	mov    %eax,0x4(%esp)
  802865:	8b 45 08             	mov    0x8(%ebp),%eax
  802868:	89 04 24             	mov    %eax,(%esp)
  80286b:	e8 65 ff ff ff       	call   8027d5 <memmove>
}
  802870:	c9                   	leave  
  802871:	c3                   	ret    

00802872 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  802872:	55                   	push   %ebp
  802873:	89 e5                	mov    %esp,%ebp
  802875:	57                   	push   %edi
  802876:	56                   	push   %esi
  802877:	53                   	push   %ebx
  802878:	8b 75 08             	mov    0x8(%ebp),%esi
  80287b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80287e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  802881:	85 c9                	test   %ecx,%ecx
  802883:	74 36                	je     8028bb <memcmp+0x49>
		if (*s1 != *s2)
  802885:	0f b6 06             	movzbl (%esi),%eax
  802888:	0f b6 1f             	movzbl (%edi),%ebx
  80288b:	38 d8                	cmp    %bl,%al
  80288d:	74 20                	je     8028af <memcmp+0x3d>
  80288f:	eb 14                	jmp    8028a5 <memcmp+0x33>
  802891:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  802896:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  80289b:	83 c2 01             	add    $0x1,%edx
  80289e:	83 e9 01             	sub    $0x1,%ecx
  8028a1:	38 d8                	cmp    %bl,%al
  8028a3:	74 12                	je     8028b7 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  8028a5:	0f b6 c0             	movzbl %al,%eax
  8028a8:	0f b6 db             	movzbl %bl,%ebx
  8028ab:	29 d8                	sub    %ebx,%eax
  8028ad:	eb 11                	jmp    8028c0 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  8028af:	83 e9 01             	sub    $0x1,%ecx
  8028b2:	ba 00 00 00 00       	mov    $0x0,%edx
  8028b7:	85 c9                	test   %ecx,%ecx
  8028b9:	75 d6                	jne    802891 <memcmp+0x1f>
  8028bb:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  8028c0:	5b                   	pop    %ebx
  8028c1:	5e                   	pop    %esi
  8028c2:	5f                   	pop    %edi
  8028c3:	5d                   	pop    %ebp
  8028c4:	c3                   	ret    

008028c5 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  8028c5:	55                   	push   %ebp
  8028c6:	89 e5                	mov    %esp,%ebp
  8028c8:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  8028cb:	89 c2                	mov    %eax,%edx
  8028cd:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  8028d0:	39 d0                	cmp    %edx,%eax
  8028d2:	73 15                	jae    8028e9 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  8028d4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  8028d8:	38 08                	cmp    %cl,(%eax)
  8028da:	75 06                	jne    8028e2 <memfind+0x1d>
  8028dc:	eb 0b                	jmp    8028e9 <memfind+0x24>
  8028de:	38 08                	cmp    %cl,(%eax)
  8028e0:	74 07                	je     8028e9 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  8028e2:	83 c0 01             	add    $0x1,%eax
  8028e5:	39 c2                	cmp    %eax,%edx
  8028e7:	77 f5                	ja     8028de <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  8028e9:	5d                   	pop    %ebp
  8028ea:	c3                   	ret    

008028eb <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  8028eb:	55                   	push   %ebp
  8028ec:	89 e5                	mov    %esp,%ebp
  8028ee:	57                   	push   %edi
  8028ef:	56                   	push   %esi
  8028f0:	53                   	push   %ebx
  8028f1:	83 ec 04             	sub    $0x4,%esp
  8028f4:	8b 55 08             	mov    0x8(%ebp),%edx
  8028f7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  8028fa:	0f b6 02             	movzbl (%edx),%eax
  8028fd:	3c 20                	cmp    $0x20,%al
  8028ff:	74 04                	je     802905 <strtol+0x1a>
  802901:	3c 09                	cmp    $0x9,%al
  802903:	75 0e                	jne    802913 <strtol+0x28>
		s++;
  802905:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  802908:	0f b6 02             	movzbl (%edx),%eax
  80290b:	3c 20                	cmp    $0x20,%al
  80290d:	74 f6                	je     802905 <strtol+0x1a>
  80290f:	3c 09                	cmp    $0x9,%al
  802911:	74 f2                	je     802905 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  802913:	3c 2b                	cmp    $0x2b,%al
  802915:	75 0c                	jne    802923 <strtol+0x38>
		s++;
  802917:	83 c2 01             	add    $0x1,%edx
  80291a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  802921:	eb 15                	jmp    802938 <strtol+0x4d>
	else if (*s == '-')
  802923:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  80292a:	3c 2d                	cmp    $0x2d,%al
  80292c:	75 0a                	jne    802938 <strtol+0x4d>
		s++, neg = 1;
  80292e:	83 c2 01             	add    $0x1,%edx
  802931:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  802938:	85 db                	test   %ebx,%ebx
  80293a:	0f 94 c0             	sete   %al
  80293d:	74 05                	je     802944 <strtol+0x59>
  80293f:	83 fb 10             	cmp    $0x10,%ebx
  802942:	75 18                	jne    80295c <strtol+0x71>
  802944:	80 3a 30             	cmpb   $0x30,(%edx)
  802947:	75 13                	jne    80295c <strtol+0x71>
  802949:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  80294d:	8d 76 00             	lea    0x0(%esi),%esi
  802950:	75 0a                	jne    80295c <strtol+0x71>
		s += 2, base = 16;
  802952:	83 c2 02             	add    $0x2,%edx
  802955:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  80295a:	eb 15                	jmp    802971 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  80295c:	84 c0                	test   %al,%al
  80295e:	66 90                	xchg   %ax,%ax
  802960:	74 0f                	je     802971 <strtol+0x86>
  802962:	bb 0a 00 00 00       	mov    $0xa,%ebx
  802967:	80 3a 30             	cmpb   $0x30,(%edx)
  80296a:	75 05                	jne    802971 <strtol+0x86>
		s++, base = 8;
  80296c:	83 c2 01             	add    $0x1,%edx
  80296f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  802971:	b8 00 00 00 00       	mov    $0x0,%eax
  802976:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  802978:	0f b6 0a             	movzbl (%edx),%ecx
  80297b:	89 cf                	mov    %ecx,%edi
  80297d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  802980:	80 fb 09             	cmp    $0x9,%bl
  802983:	77 08                	ja     80298d <strtol+0xa2>
			dig = *s - '0';
  802985:	0f be c9             	movsbl %cl,%ecx
  802988:	83 e9 30             	sub    $0x30,%ecx
  80298b:	eb 1e                	jmp    8029ab <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  80298d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  802990:	80 fb 19             	cmp    $0x19,%bl
  802993:	77 08                	ja     80299d <strtol+0xb2>
			dig = *s - 'a' + 10;
  802995:	0f be c9             	movsbl %cl,%ecx
  802998:	83 e9 57             	sub    $0x57,%ecx
  80299b:	eb 0e                	jmp    8029ab <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  80299d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  8029a0:	80 fb 19             	cmp    $0x19,%bl
  8029a3:	77 15                	ja     8029ba <strtol+0xcf>
			dig = *s - 'A' + 10;
  8029a5:	0f be c9             	movsbl %cl,%ecx
  8029a8:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  8029ab:	39 f1                	cmp    %esi,%ecx
  8029ad:	7d 0b                	jge    8029ba <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  8029af:	83 c2 01             	add    $0x1,%edx
  8029b2:	0f af c6             	imul   %esi,%eax
  8029b5:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  8029b8:	eb be                	jmp    802978 <strtol+0x8d>
  8029ba:	89 c1                	mov    %eax,%ecx

	if (endptr)
  8029bc:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  8029c0:	74 05                	je     8029c7 <strtol+0xdc>
		*endptr = (char *) s;
  8029c2:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8029c5:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  8029c7:	89 ca                	mov    %ecx,%edx
  8029c9:	f7 da                	neg    %edx
  8029cb:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  8029cf:	0f 45 c2             	cmovne %edx,%eax
}
  8029d2:	83 c4 04             	add    $0x4,%esp
  8029d5:	5b                   	pop    %ebx
  8029d6:	5e                   	pop    %esi
  8029d7:	5f                   	pop    %edi
  8029d8:	5d                   	pop    %ebp
  8029d9:	c3                   	ret    
	...

008029dc <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  8029dc:	55                   	push   %ebp
  8029dd:	89 e5                	mov    %esp,%ebp
  8029df:	83 ec 0c             	sub    $0xc,%esp
  8029e2:	89 1c 24             	mov    %ebx,(%esp)
  8029e5:	89 74 24 04          	mov    %esi,0x4(%esp)
  8029e9:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8029ed:	ba 00 00 00 00       	mov    $0x0,%edx
  8029f2:	b8 01 00 00 00       	mov    $0x1,%eax
  8029f7:	89 d1                	mov    %edx,%ecx
  8029f9:	89 d3                	mov    %edx,%ebx
  8029fb:	89 d7                	mov    %edx,%edi
  8029fd:	89 d6                	mov    %edx,%esi
  8029ff:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  802a01:	8b 1c 24             	mov    (%esp),%ebx
  802a04:	8b 74 24 04          	mov    0x4(%esp),%esi
  802a08:	8b 7c 24 08          	mov    0x8(%esp),%edi
  802a0c:	89 ec                	mov    %ebp,%esp
  802a0e:	5d                   	pop    %ebp
  802a0f:	c3                   	ret    

00802a10 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  802a10:	55                   	push   %ebp
  802a11:	89 e5                	mov    %esp,%ebp
  802a13:	83 ec 0c             	sub    $0xc,%esp
  802a16:	89 1c 24             	mov    %ebx,(%esp)
  802a19:	89 74 24 04          	mov    %esi,0x4(%esp)
  802a1d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802a21:	b8 00 00 00 00       	mov    $0x0,%eax
  802a26:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802a29:	8b 55 08             	mov    0x8(%ebp),%edx
  802a2c:	89 c3                	mov    %eax,%ebx
  802a2e:	89 c7                	mov    %eax,%edi
  802a30:	89 c6                	mov    %eax,%esi
  802a32:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  802a34:	8b 1c 24             	mov    (%esp),%ebx
  802a37:	8b 74 24 04          	mov    0x4(%esp),%esi
  802a3b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  802a3f:	89 ec                	mov    %ebp,%esp
  802a41:	5d                   	pop    %ebp
  802a42:	c3                   	ret    

00802a43 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  802a43:	55                   	push   %ebp
  802a44:	89 e5                	mov    %esp,%ebp
  802a46:	83 ec 0c             	sub    $0xc,%esp
  802a49:	89 1c 24             	mov    %ebx,(%esp)
  802a4c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802a50:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802a54:	bb 00 00 00 00       	mov    $0x0,%ebx
  802a59:	b8 10 00 00 00       	mov    $0x10,%eax
  802a5e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802a61:	8b 55 08             	mov    0x8(%ebp),%edx
  802a64:	89 df                	mov    %ebx,%edi
  802a66:	89 de                	mov    %ebx,%esi
  802a68:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  802a6a:	8b 1c 24             	mov    (%esp),%ebx
  802a6d:	8b 74 24 04          	mov    0x4(%esp),%esi
  802a71:	8b 7c 24 08          	mov    0x8(%esp),%edi
  802a75:	89 ec                	mov    %ebp,%esp
  802a77:	5d                   	pop    %ebp
  802a78:	c3                   	ret    

00802a79 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  802a79:	55                   	push   %ebp
  802a7a:	89 e5                	mov    %esp,%ebp
  802a7c:	83 ec 0c             	sub    $0xc,%esp
  802a7f:	89 1c 24             	mov    %ebx,(%esp)
  802a82:	89 74 24 04          	mov    %esi,0x4(%esp)
  802a86:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802a8a:	bb 00 00 00 00       	mov    $0x0,%ebx
  802a8f:	b8 0f 00 00 00       	mov    $0xf,%eax
  802a94:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802a97:	8b 55 08             	mov    0x8(%ebp),%edx
  802a9a:	89 df                	mov    %ebx,%edi
  802a9c:	89 de                	mov    %ebx,%esi
  802a9e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  802aa0:	8b 1c 24             	mov    (%esp),%ebx
  802aa3:	8b 74 24 04          	mov    0x4(%esp),%esi
  802aa7:	8b 7c 24 08          	mov    0x8(%esp),%edi
  802aab:	89 ec                	mov    %ebp,%esp
  802aad:	5d                   	pop    %ebp
  802aae:	c3                   	ret    

00802aaf <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  802aaf:	55                   	push   %ebp
  802ab0:	89 e5                	mov    %esp,%ebp
  802ab2:	83 ec 0c             	sub    $0xc,%esp
  802ab5:	89 1c 24             	mov    %ebx,(%esp)
  802ab8:	89 74 24 04          	mov    %esi,0x4(%esp)
  802abc:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802ac0:	ba 00 00 00 00       	mov    $0x0,%edx
  802ac5:	b8 0e 00 00 00       	mov    $0xe,%eax
  802aca:	89 d1                	mov    %edx,%ecx
  802acc:	89 d3                	mov    %edx,%ebx
  802ace:	89 d7                	mov    %edx,%edi
  802ad0:	89 d6                	mov    %edx,%esi
  802ad2:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  802ad4:	8b 1c 24             	mov    (%esp),%ebx
  802ad7:	8b 74 24 04          	mov    0x4(%esp),%esi
  802adb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  802adf:	89 ec                	mov    %ebp,%esp
  802ae1:	5d                   	pop    %ebp
  802ae2:	c3                   	ret    

00802ae3 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  802ae3:	55                   	push   %ebp
  802ae4:	89 e5                	mov    %esp,%ebp
  802ae6:	83 ec 38             	sub    $0x38,%esp
  802ae9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802aec:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802aef:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802af2:	b9 00 00 00 00       	mov    $0x0,%ecx
  802af7:	b8 0d 00 00 00       	mov    $0xd,%eax
  802afc:	8b 55 08             	mov    0x8(%ebp),%edx
  802aff:	89 cb                	mov    %ecx,%ebx
  802b01:	89 cf                	mov    %ecx,%edi
  802b03:	89 ce                	mov    %ecx,%esi
  802b05:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802b07:	85 c0                	test   %eax,%eax
  802b09:	7e 28                	jle    802b33 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  802b0b:	89 44 24 10          	mov    %eax,0x10(%esp)
  802b0f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  802b16:	00 
  802b17:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802b1e:	00 
  802b1f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802b26:	00 
  802b27:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802b2e:	e8 4d f3 ff ff       	call   801e80 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  802b33:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802b36:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802b39:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802b3c:	89 ec                	mov    %ebp,%esp
  802b3e:	5d                   	pop    %ebp
  802b3f:	c3                   	ret    

00802b40 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  802b40:	55                   	push   %ebp
  802b41:	89 e5                	mov    %esp,%ebp
  802b43:	83 ec 38             	sub    $0x38,%esp
  802b46:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802b49:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802b4c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802b4f:	be 00 00 00 00       	mov    $0x0,%esi
  802b54:	b8 0c 00 00 00       	mov    $0xc,%eax
  802b59:	8b 7d 14             	mov    0x14(%ebp),%edi
  802b5c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802b5f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802b62:	8b 55 08             	mov    0x8(%ebp),%edx
  802b65:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802b67:	85 c0                	test   %eax,%eax
  802b69:	7e 28                	jle    802b93 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  802b6b:	89 44 24 10          	mov    %eax,0x10(%esp)
  802b6f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  802b76:	00 
  802b77:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802b7e:	00 
  802b7f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802b86:	00 
  802b87:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802b8e:	e8 ed f2 ff ff       	call   801e80 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  802b93:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802b96:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802b99:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802b9c:	89 ec                	mov    %ebp,%esp
  802b9e:	5d                   	pop    %ebp
  802b9f:	c3                   	ret    

00802ba0 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  802ba0:	55                   	push   %ebp
  802ba1:	89 e5                	mov    %esp,%ebp
  802ba3:	83 ec 38             	sub    $0x38,%esp
  802ba6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802ba9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802bac:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802baf:	bb 00 00 00 00       	mov    $0x0,%ebx
  802bb4:	b8 0a 00 00 00       	mov    $0xa,%eax
  802bb9:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802bbc:	8b 55 08             	mov    0x8(%ebp),%edx
  802bbf:	89 df                	mov    %ebx,%edi
  802bc1:	89 de                	mov    %ebx,%esi
  802bc3:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802bc5:	85 c0                	test   %eax,%eax
  802bc7:	7e 28                	jle    802bf1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  802bc9:	89 44 24 10          	mov    %eax,0x10(%esp)
  802bcd:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  802bd4:	00 
  802bd5:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802bdc:	00 
  802bdd:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802be4:	00 
  802be5:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802bec:	e8 8f f2 ff ff       	call   801e80 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  802bf1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802bf4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802bf7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802bfa:	89 ec                	mov    %ebp,%esp
  802bfc:	5d                   	pop    %ebp
  802bfd:	c3                   	ret    

00802bfe <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  802bfe:	55                   	push   %ebp
  802bff:	89 e5                	mov    %esp,%ebp
  802c01:	83 ec 38             	sub    $0x38,%esp
  802c04:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802c07:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802c0a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802c0d:	bb 00 00 00 00       	mov    $0x0,%ebx
  802c12:	b8 09 00 00 00       	mov    $0x9,%eax
  802c17:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802c1a:	8b 55 08             	mov    0x8(%ebp),%edx
  802c1d:	89 df                	mov    %ebx,%edi
  802c1f:	89 de                	mov    %ebx,%esi
  802c21:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802c23:	85 c0                	test   %eax,%eax
  802c25:	7e 28                	jle    802c4f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  802c27:	89 44 24 10          	mov    %eax,0x10(%esp)
  802c2b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  802c32:	00 
  802c33:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802c3a:	00 
  802c3b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802c42:	00 
  802c43:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802c4a:	e8 31 f2 ff ff       	call   801e80 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  802c4f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802c52:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802c55:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802c58:	89 ec                	mov    %ebp,%esp
  802c5a:	5d                   	pop    %ebp
  802c5b:	c3                   	ret    

00802c5c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  802c5c:	55                   	push   %ebp
  802c5d:	89 e5                	mov    %esp,%ebp
  802c5f:	83 ec 38             	sub    $0x38,%esp
  802c62:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802c65:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802c68:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802c6b:	bb 00 00 00 00       	mov    $0x0,%ebx
  802c70:	b8 08 00 00 00       	mov    $0x8,%eax
  802c75:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802c78:	8b 55 08             	mov    0x8(%ebp),%edx
  802c7b:	89 df                	mov    %ebx,%edi
  802c7d:	89 de                	mov    %ebx,%esi
  802c7f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802c81:	85 c0                	test   %eax,%eax
  802c83:	7e 28                	jle    802cad <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  802c85:	89 44 24 10          	mov    %eax,0x10(%esp)
  802c89:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  802c90:	00 
  802c91:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802c98:	00 
  802c99:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802ca0:	00 
  802ca1:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802ca8:	e8 d3 f1 ff ff       	call   801e80 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  802cad:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802cb0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802cb3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802cb6:	89 ec                	mov    %ebp,%esp
  802cb8:	5d                   	pop    %ebp
  802cb9:	c3                   	ret    

00802cba <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  802cba:	55                   	push   %ebp
  802cbb:	89 e5                	mov    %esp,%ebp
  802cbd:	83 ec 38             	sub    $0x38,%esp
  802cc0:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802cc3:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802cc6:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802cc9:	bb 00 00 00 00       	mov    $0x0,%ebx
  802cce:	b8 06 00 00 00       	mov    $0x6,%eax
  802cd3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802cd6:	8b 55 08             	mov    0x8(%ebp),%edx
  802cd9:	89 df                	mov    %ebx,%edi
  802cdb:	89 de                	mov    %ebx,%esi
  802cdd:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802cdf:	85 c0                	test   %eax,%eax
  802ce1:	7e 28                	jle    802d0b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  802ce3:	89 44 24 10          	mov    %eax,0x10(%esp)
  802ce7:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  802cee:	00 
  802cef:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802cf6:	00 
  802cf7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802cfe:	00 
  802cff:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802d06:	e8 75 f1 ff ff       	call   801e80 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  802d0b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802d0e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802d11:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802d14:	89 ec                	mov    %ebp,%esp
  802d16:	5d                   	pop    %ebp
  802d17:	c3                   	ret    

00802d18 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  802d18:	55                   	push   %ebp
  802d19:	89 e5                	mov    %esp,%ebp
  802d1b:	83 ec 38             	sub    $0x38,%esp
  802d1e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802d21:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802d24:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802d27:	b8 05 00 00 00       	mov    $0x5,%eax
  802d2c:	8b 75 18             	mov    0x18(%ebp),%esi
  802d2f:	8b 7d 14             	mov    0x14(%ebp),%edi
  802d32:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802d35:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802d38:	8b 55 08             	mov    0x8(%ebp),%edx
  802d3b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802d3d:	85 c0                	test   %eax,%eax
  802d3f:	7e 28                	jle    802d69 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  802d41:	89 44 24 10          	mov    %eax,0x10(%esp)
  802d45:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  802d4c:	00 
  802d4d:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802d54:	00 
  802d55:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802d5c:	00 
  802d5d:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802d64:	e8 17 f1 ff ff       	call   801e80 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  802d69:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802d6c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802d6f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802d72:	89 ec                	mov    %ebp,%esp
  802d74:	5d                   	pop    %ebp
  802d75:	c3                   	ret    

00802d76 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  802d76:	55                   	push   %ebp
  802d77:	89 e5                	mov    %esp,%ebp
  802d79:	83 ec 38             	sub    $0x38,%esp
  802d7c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802d7f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802d82:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802d85:	be 00 00 00 00       	mov    $0x0,%esi
  802d8a:	b8 04 00 00 00       	mov    $0x4,%eax
  802d8f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802d92:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802d95:	8b 55 08             	mov    0x8(%ebp),%edx
  802d98:	89 f7                	mov    %esi,%edi
  802d9a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802d9c:	85 c0                	test   %eax,%eax
  802d9e:	7e 28                	jle    802dc8 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  802da0:	89 44 24 10          	mov    %eax,0x10(%esp)
  802da4:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  802dab:	00 
  802dac:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802db3:	00 
  802db4:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802dbb:	00 
  802dbc:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802dc3:	e8 b8 f0 ff ff       	call   801e80 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  802dc8:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802dcb:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802dce:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802dd1:	89 ec                	mov    %ebp,%esp
  802dd3:	5d                   	pop    %ebp
  802dd4:	c3                   	ret    

00802dd5 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  802dd5:	55                   	push   %ebp
  802dd6:	89 e5                	mov    %esp,%ebp
  802dd8:	83 ec 0c             	sub    $0xc,%esp
  802ddb:	89 1c 24             	mov    %ebx,(%esp)
  802dde:	89 74 24 04          	mov    %esi,0x4(%esp)
  802de2:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802de6:	ba 00 00 00 00       	mov    $0x0,%edx
  802deb:	b8 0b 00 00 00       	mov    $0xb,%eax
  802df0:	89 d1                	mov    %edx,%ecx
  802df2:	89 d3                	mov    %edx,%ebx
  802df4:	89 d7                	mov    %edx,%edi
  802df6:	89 d6                	mov    %edx,%esi
  802df8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  802dfa:	8b 1c 24             	mov    (%esp),%ebx
  802dfd:	8b 74 24 04          	mov    0x4(%esp),%esi
  802e01:	8b 7c 24 08          	mov    0x8(%esp),%edi
  802e05:	89 ec                	mov    %ebp,%esp
  802e07:	5d                   	pop    %ebp
  802e08:	c3                   	ret    

00802e09 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  802e09:	55                   	push   %ebp
  802e0a:	89 e5                	mov    %esp,%ebp
  802e0c:	83 ec 0c             	sub    $0xc,%esp
  802e0f:	89 1c 24             	mov    %ebx,(%esp)
  802e12:	89 74 24 04          	mov    %esi,0x4(%esp)
  802e16:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802e1a:	ba 00 00 00 00       	mov    $0x0,%edx
  802e1f:	b8 02 00 00 00       	mov    $0x2,%eax
  802e24:	89 d1                	mov    %edx,%ecx
  802e26:	89 d3                	mov    %edx,%ebx
  802e28:	89 d7                	mov    %edx,%edi
  802e2a:	89 d6                	mov    %edx,%esi
  802e2c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  802e2e:	8b 1c 24             	mov    (%esp),%ebx
  802e31:	8b 74 24 04          	mov    0x4(%esp),%esi
  802e35:	8b 7c 24 08          	mov    0x8(%esp),%edi
  802e39:	89 ec                	mov    %ebp,%esp
  802e3b:	5d                   	pop    %ebp
  802e3c:	c3                   	ret    

00802e3d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  802e3d:	55                   	push   %ebp
  802e3e:	89 e5                	mov    %esp,%ebp
  802e40:	83 ec 38             	sub    $0x38,%esp
  802e43:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802e46:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802e49:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  802e4c:	b9 00 00 00 00       	mov    $0x0,%ecx
  802e51:	b8 03 00 00 00       	mov    $0x3,%eax
  802e56:	8b 55 08             	mov    0x8(%ebp),%edx
  802e59:	89 cb                	mov    %ecx,%ebx
  802e5b:	89 cf                	mov    %ecx,%edi
  802e5d:	89 ce                	mov    %ecx,%esi
  802e5f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  802e61:	85 c0                	test   %eax,%eax
  802e63:	7e 28                	jle    802e8d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  802e65:	89 44 24 10          	mov    %eax,0x10(%esp)
  802e69:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  802e70:	00 
  802e71:	c7 44 24 08 4b 4f 80 	movl   $0x804f4b,0x8(%esp)
  802e78:	00 
  802e79:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  802e80:	00 
  802e81:	c7 04 24 68 4f 80 00 	movl   $0x804f68,(%esp)
  802e88:	e8 f3 ef ff ff       	call   801e80 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  802e8d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802e90:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802e93:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802e96:	89 ec                	mov    %ebp,%esp
  802e98:	5d                   	pop    %ebp
  802e99:	c3                   	ret    
	...

00802e9c <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802e9c:	55                   	push   %ebp
  802e9d:	89 e5                	mov    %esp,%ebp
  802e9f:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  802ea2:	83 3d e8 d0 80 00 00 	cmpl   $0x0,0x80d0e8
  802ea9:	75 55                	jne    802f00 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802eab:	e8 59 ff ff ff       	call   802e09 <sys_getenvid>
  802eb0:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802eb7:	00 
  802eb8:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802ebf:	ee 
  802ec0:	89 04 24             	mov    %eax,(%esp)
  802ec3:	e8 ae fe ff ff       	call   802d76 <sys_page_alloc>
  802ec8:	85 c0                	test   %eax,%eax
  802eca:	74 1c                	je     802ee8 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802ecc:	c7 44 24 08 78 4f 80 	movl   $0x804f78,0x8(%esp)
  802ed3:	00 
  802ed4:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802edb:	00 
  802edc:	c7 04 24 9c 4f 80 00 	movl   $0x804f9c,(%esp)
  802ee3:	e8 98 ef ff ff       	call   801e80 <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802ee8:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  802eed:	8b 40 4c             	mov    0x4c(%eax),%eax
  802ef0:	c7 44 24 04 0c 2f 80 	movl   $0x802f0c,0x4(%esp)
  802ef7:	00 
  802ef8:	89 04 24             	mov    %eax,(%esp)
  802efb:	e8 a0 fc ff ff       	call   802ba0 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802f00:	8b 45 08             	mov    0x8(%ebp),%eax
  802f03:	a3 e8 d0 80 00       	mov    %eax,0x80d0e8
}
  802f08:	c9                   	leave  
  802f09:	c3                   	ret    
	...

00802f0c <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802f0c:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802f0d:	a1 e8 d0 80 00       	mov    0x80d0e8,%eax
	call *%eax
  802f12:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802f14:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802f17:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802f1c:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  802f20:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  802f24:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  802f26:	83 c4 08             	add    $0x8,%esp
    popal
  802f29:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  802f2a:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  802f2e:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  802f2f:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  802f33:	c3                   	ret    
	...

00802f40 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802f40:	55                   	push   %ebp
  802f41:	89 e5                	mov    %esp,%ebp
  802f43:	57                   	push   %edi
  802f44:	56                   	push   %esi
  802f45:	53                   	push   %ebx
  802f46:	83 ec 2c             	sub    $0x2c,%esp
  802f49:	8b 75 08             	mov    0x8(%ebp),%esi
  802f4c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802f4f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802f52:	85 db                	test   %ebx,%ebx
  802f54:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802f59:	0f 45 c3             	cmovne %ebx,%eax
  802f5c:	8b 55 14             	mov    0x14(%ebp),%edx
  802f5f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802f63:	89 44 24 08          	mov    %eax,0x8(%esp)
  802f67:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802f6b:	89 34 24             	mov    %esi,(%esp)
  802f6e:	e8 cd fb ff ff       	call   802b40 <sys_ipc_try_send>
  802f73:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802f76:	75 0a                	jne    802f82 <ipc_send+0x42>
      sys_yield();
  802f78:	e8 58 fe ff ff       	call   802dd5 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  802f7d:	8d 76 00             	lea    0x0(%esi),%esi
  802f80:	eb d0                	jmp    802f52 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802f82:	85 c0                	test   %eax,%eax
  802f84:	79 24                	jns    802faa <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802f86:	89 44 24 10          	mov    %eax,0x10(%esp)
  802f8a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802f8e:	c7 44 24 08 ac 4f 80 	movl   $0x804fac,0x8(%esp)
  802f95:	00 
  802f96:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  802f9d:	00 
  802f9e:	c7 04 24 d0 4f 80 00 	movl   $0x804fd0,(%esp)
  802fa5:	e8 d6 ee ff ff       	call   801e80 <_panic>
    else
      return;
  }
}
  802faa:	83 c4 2c             	add    $0x2c,%esp
  802fad:	5b                   	pop    %ebx
  802fae:	5e                   	pop    %esi
  802faf:	5f                   	pop    %edi
  802fb0:	5d                   	pop    %ebp
  802fb1:	c3                   	ret    

00802fb2 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802fb2:	55                   	push   %ebp
  802fb3:	89 e5                	mov    %esp,%ebp
  802fb5:	56                   	push   %esi
  802fb6:	53                   	push   %ebx
  802fb7:	83 ec 10             	sub    $0x10,%esp
  802fba:	8b 5d 08             	mov    0x8(%ebp),%ebx
  802fbd:	8b 45 0c             	mov    0xc(%ebp),%eax
  802fc0:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802fc3:	85 c0                	test   %eax,%eax
  802fc5:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  802fca:	0f 44 c2             	cmove  %edx,%eax
  802fcd:	89 04 24             	mov    %eax,(%esp)
  802fd0:	e8 0e fb ff ff       	call   802ae3 <sys_ipc_recv>
  802fd5:	85 c0                	test   %eax,%eax
  802fd7:	78 24                	js     802ffd <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802fd9:	85 db                	test   %ebx,%ebx
  802fdb:	74 0a                	je     802fe7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  802fdd:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  802fe2:	8b 40 74             	mov    0x74(%eax),%eax
  802fe5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802fe7:	85 f6                	test   %esi,%esi
  802fe9:	74 0a                	je     802ff5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  802feb:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  802ff0:	8b 40 78             	mov    0x78(%eax),%eax
  802ff3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802ff5:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  802ffa:	8b 40 70             	mov    0x70(%eax),%eax
}
  802ffd:	83 c4 10             	add    $0x10,%esp
  803000:	5b                   	pop    %ebx
  803001:	5e                   	pop    %esi
  803002:	5d                   	pop    %ebp
  803003:	c3                   	ret    
	...

00803010 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  803010:	55                   	push   %ebp
  803011:	89 e5                	mov    %esp,%ebp
  803013:	8b 45 08             	mov    0x8(%ebp),%eax
  803016:	05 00 00 00 30       	add    $0x30000000,%eax
  80301b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80301e:	5d                   	pop    %ebp
  80301f:	c3                   	ret    

00803020 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  803020:	55                   	push   %ebp
  803021:	89 e5                	mov    %esp,%ebp
  803023:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  803026:	8b 45 08             	mov    0x8(%ebp),%eax
  803029:	89 04 24             	mov    %eax,(%esp)
  80302c:	e8 df ff ff ff       	call   803010 <fd2num>
  803031:	05 20 00 0d 00       	add    $0xd0020,%eax
  803036:	c1 e0 0c             	shl    $0xc,%eax
}
  803039:	c9                   	leave  
  80303a:	c3                   	ret    

0080303b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80303b:	55                   	push   %ebp
  80303c:	89 e5                	mov    %esp,%ebp
  80303e:	57                   	push   %edi
  80303f:	56                   	push   %esi
  803040:	53                   	push   %ebx
  803041:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  803044:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  803049:	a8 01                	test   $0x1,%al
  80304b:	74 36                	je     803083 <fd_alloc+0x48>
  80304d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  803052:	a8 01                	test   $0x1,%al
  803054:	74 2d                	je     803083 <fd_alloc+0x48>
  803056:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80305b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  803060:	be 00 00 40 ef       	mov    $0xef400000,%esi
  803065:	89 c3                	mov    %eax,%ebx
  803067:	89 c2                	mov    %eax,%edx
  803069:	c1 ea 16             	shr    $0x16,%edx
  80306c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80306f:	f6 c2 01             	test   $0x1,%dl
  803072:	74 14                	je     803088 <fd_alloc+0x4d>
  803074:	89 c2                	mov    %eax,%edx
  803076:	c1 ea 0c             	shr    $0xc,%edx
  803079:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80307c:	f6 c2 01             	test   $0x1,%dl
  80307f:	75 10                	jne    803091 <fd_alloc+0x56>
  803081:	eb 05                	jmp    803088 <fd_alloc+0x4d>
  803083:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  803088:	89 1f                	mov    %ebx,(%edi)
  80308a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80308f:	eb 17                	jmp    8030a8 <fd_alloc+0x6d>
  803091:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  803096:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80309b:	75 c8                	jne    803065 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80309d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8030a3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8030a8:	5b                   	pop    %ebx
  8030a9:	5e                   	pop    %esi
  8030aa:	5f                   	pop    %edi
  8030ab:	5d                   	pop    %ebp
  8030ac:	c3                   	ret    

008030ad <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8030ad:	55                   	push   %ebp
  8030ae:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8030b0:	8b 45 08             	mov    0x8(%ebp),%eax
  8030b3:	83 f8 1f             	cmp    $0x1f,%eax
  8030b6:	77 36                	ja     8030ee <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8030b8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8030bd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  8030c0:	89 c2                	mov    %eax,%edx
  8030c2:	c1 ea 16             	shr    $0x16,%edx
  8030c5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8030cc:	f6 c2 01             	test   $0x1,%dl
  8030cf:	74 1d                	je     8030ee <fd_lookup+0x41>
  8030d1:	89 c2                	mov    %eax,%edx
  8030d3:	c1 ea 0c             	shr    $0xc,%edx
  8030d6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8030dd:	f6 c2 01             	test   $0x1,%dl
  8030e0:	74 0c                	je     8030ee <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8030e2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8030e5:	89 02                	mov    %eax,(%edx)
  8030e7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8030ec:	eb 05                	jmp    8030f3 <fd_lookup+0x46>
  8030ee:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8030f3:	5d                   	pop    %ebp
  8030f4:	c3                   	ret    

008030f5 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  8030f5:	55                   	push   %ebp
  8030f6:	89 e5                	mov    %esp,%ebp
  8030f8:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8030fb:	8d 45 fc             	lea    -0x4(%ebp),%eax
  8030fe:	89 44 24 04          	mov    %eax,0x4(%esp)
  803102:	8b 45 08             	mov    0x8(%ebp),%eax
  803105:	89 04 24             	mov    %eax,(%esp)
  803108:	e8 a0 ff ff ff       	call   8030ad <fd_lookup>
  80310d:	85 c0                	test   %eax,%eax
  80310f:	78 0e                	js     80311f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  803111:	8b 45 fc             	mov    -0x4(%ebp),%eax
  803114:	8b 55 0c             	mov    0xc(%ebp),%edx
  803117:	89 50 04             	mov    %edx,0x4(%eax)
  80311a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80311f:	c9                   	leave  
  803120:	c3                   	ret    

00803121 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  803121:	55                   	push   %ebp
  803122:	89 e5                	mov    %esp,%ebp
  803124:	56                   	push   %esi
  803125:	53                   	push   %ebx
  803126:	83 ec 10             	sub    $0x10,%esp
  803129:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80312c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80312f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  803134:	b8 68 d0 80 00       	mov    $0x80d068,%eax
  803139:	39 0d 68 d0 80 00    	cmp    %ecx,0x80d068
  80313f:	75 11                	jne    803152 <dev_lookup+0x31>
  803141:	eb 04                	jmp    803147 <dev_lookup+0x26>
  803143:	39 08                	cmp    %ecx,(%eax)
  803145:	75 10                	jne    803157 <dev_lookup+0x36>
			*dev = devtab[i];
  803147:	89 03                	mov    %eax,(%ebx)
  803149:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80314e:	66 90                	xchg   %ax,%ax
  803150:	eb 36                	jmp    803188 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  803152:	be 5c 50 80 00       	mov    $0x80505c,%esi
  803157:	83 c2 01             	add    $0x1,%edx
  80315a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80315d:	85 c0                	test   %eax,%eax
  80315f:	75 e2                	jne    803143 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  803161:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  803166:	8b 40 4c             	mov    0x4c(%eax),%eax
  803169:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80316d:	89 44 24 04          	mov    %eax,0x4(%esp)
  803171:	c7 04 24 dc 4f 80 00 	movl   $0x804fdc,(%esp)
  803178:	e8 c8 ed ff ff       	call   801f45 <cprintf>
	*dev = 0;
  80317d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  803183:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  803188:	83 c4 10             	add    $0x10,%esp
  80318b:	5b                   	pop    %ebx
  80318c:	5e                   	pop    %esi
  80318d:	5d                   	pop    %ebp
  80318e:	c3                   	ret    

0080318f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80318f:	55                   	push   %ebp
  803190:	89 e5                	mov    %esp,%ebp
  803192:	53                   	push   %ebx
  803193:	83 ec 24             	sub    $0x24,%esp
  803196:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  803199:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80319c:	89 44 24 04          	mov    %eax,0x4(%esp)
  8031a0:	8b 45 08             	mov    0x8(%ebp),%eax
  8031a3:	89 04 24             	mov    %eax,(%esp)
  8031a6:	e8 02 ff ff ff       	call   8030ad <fd_lookup>
  8031ab:	85 c0                	test   %eax,%eax
  8031ad:	78 53                	js     803202 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8031af:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8031b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8031b6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8031b9:	8b 00                	mov    (%eax),%eax
  8031bb:	89 04 24             	mov    %eax,(%esp)
  8031be:	e8 5e ff ff ff       	call   803121 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8031c3:	85 c0                	test   %eax,%eax
  8031c5:	78 3b                	js     803202 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  8031c7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8031cc:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8031cf:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8031d3:	74 2d                	je     803202 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8031d5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8031d8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8031df:	00 00 00 
	stat->st_isdir = 0;
  8031e2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8031e9:	00 00 00 
	stat->st_dev = dev;
  8031ec:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8031ef:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  8031f5:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8031f9:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8031fc:	89 14 24             	mov    %edx,(%esp)
  8031ff:	ff 50 14             	call   *0x14(%eax)
}
  803202:	83 c4 24             	add    $0x24,%esp
  803205:	5b                   	pop    %ebx
  803206:	5d                   	pop    %ebp
  803207:	c3                   	ret    

00803208 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  803208:	55                   	push   %ebp
  803209:	89 e5                	mov    %esp,%ebp
  80320b:	53                   	push   %ebx
  80320c:	83 ec 24             	sub    $0x24,%esp
  80320f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  803212:	8d 45 f0             	lea    -0x10(%ebp),%eax
  803215:	89 44 24 04          	mov    %eax,0x4(%esp)
  803219:	89 1c 24             	mov    %ebx,(%esp)
  80321c:	e8 8c fe ff ff       	call   8030ad <fd_lookup>
  803221:	85 c0                	test   %eax,%eax
  803223:	78 5f                	js     803284 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  803225:	8d 45 f4             	lea    -0xc(%ebp),%eax
  803228:	89 44 24 04          	mov    %eax,0x4(%esp)
  80322c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80322f:	8b 00                	mov    (%eax),%eax
  803231:	89 04 24             	mov    %eax,(%esp)
  803234:	e8 e8 fe ff ff       	call   803121 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  803239:	85 c0                	test   %eax,%eax
  80323b:	78 47                	js     803284 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80323d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  803240:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  803244:	75 23                	jne    803269 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  803246:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80324b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80324e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  803252:	89 44 24 04          	mov    %eax,0x4(%esp)
  803256:	c7 04 24 fc 4f 80 00 	movl   $0x804ffc,(%esp)
  80325d:	e8 e3 ec ff ff       	call   801f45 <cprintf>
  803262:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  803267:	eb 1b                	jmp    803284 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  803269:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80326c:	8b 48 18             	mov    0x18(%eax),%ecx
  80326f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  803274:	85 c9                	test   %ecx,%ecx
  803276:	74 0c                	je     803284 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  803278:	8b 45 0c             	mov    0xc(%ebp),%eax
  80327b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80327f:	89 14 24             	mov    %edx,(%esp)
  803282:	ff d1                	call   *%ecx
}
  803284:	83 c4 24             	add    $0x24,%esp
  803287:	5b                   	pop    %ebx
  803288:	5d                   	pop    %ebp
  803289:	c3                   	ret    

0080328a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80328a:	55                   	push   %ebp
  80328b:	89 e5                	mov    %esp,%ebp
  80328d:	53                   	push   %ebx
  80328e:	83 ec 24             	sub    $0x24,%esp
  803291:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  803294:	8d 45 f0             	lea    -0x10(%ebp),%eax
  803297:	89 44 24 04          	mov    %eax,0x4(%esp)
  80329b:	89 1c 24             	mov    %ebx,(%esp)
  80329e:	e8 0a fe ff ff       	call   8030ad <fd_lookup>
  8032a3:	85 c0                	test   %eax,%eax
  8032a5:	78 66                	js     80330d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8032a7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8032aa:	89 44 24 04          	mov    %eax,0x4(%esp)
  8032ae:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8032b1:	8b 00                	mov    (%eax),%eax
  8032b3:	89 04 24             	mov    %eax,(%esp)
  8032b6:	e8 66 fe ff ff       	call   803121 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8032bb:	85 c0                	test   %eax,%eax
  8032bd:	78 4e                	js     80330d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8032bf:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8032c2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8032c6:	75 23                	jne    8032eb <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  8032c8:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  8032cd:	8b 40 4c             	mov    0x4c(%eax),%eax
  8032d0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8032d4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8032d8:	c7 04 24 20 50 80 00 	movl   $0x805020,(%esp)
  8032df:	e8 61 ec ff ff       	call   801f45 <cprintf>
  8032e4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8032e9:	eb 22                	jmp    80330d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8032eb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8032ee:	8b 48 0c             	mov    0xc(%eax),%ecx
  8032f1:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8032f6:	85 c9                	test   %ecx,%ecx
  8032f8:	74 13                	je     80330d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  8032fa:	8b 45 10             	mov    0x10(%ebp),%eax
  8032fd:	89 44 24 08          	mov    %eax,0x8(%esp)
  803301:	8b 45 0c             	mov    0xc(%ebp),%eax
  803304:	89 44 24 04          	mov    %eax,0x4(%esp)
  803308:	89 14 24             	mov    %edx,(%esp)
  80330b:	ff d1                	call   *%ecx
}
  80330d:	83 c4 24             	add    $0x24,%esp
  803310:	5b                   	pop    %ebx
  803311:	5d                   	pop    %ebp
  803312:	c3                   	ret    

00803313 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  803313:	55                   	push   %ebp
  803314:	89 e5                	mov    %esp,%ebp
  803316:	57                   	push   %edi
  803317:	56                   	push   %esi
  803318:	53                   	push   %ebx
  803319:	83 ec 2c             	sub    $0x2c,%esp
  80331c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80331f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  803322:	8d 45 e0             	lea    -0x20(%ebp),%eax
  803325:	89 44 24 04          	mov    %eax,0x4(%esp)
  803329:	89 1c 24             	mov    %ebx,(%esp)
  80332c:	e8 7c fd ff ff       	call   8030ad <fd_lookup>
  803331:	85 c0                	test   %eax,%eax
  803333:	0f 88 b0 00 00 00    	js     8033e9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  803339:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80333c:	89 44 24 04          	mov    %eax,0x4(%esp)
  803340:	8b 45 e0             	mov    -0x20(%ebp),%eax
  803343:	8b 00                	mov    (%eax),%eax
  803345:	89 04 24             	mov    %eax,(%esp)
  803348:	e8 d4 fd ff ff       	call   803121 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80334d:	85 c0                	test   %eax,%eax
  80334f:	0f 88 94 00 00 00    	js     8033e9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  803355:	8b 45 e0             	mov    -0x20(%ebp),%eax
  803358:	8b 40 08             	mov    0x8(%eax),%eax
  80335b:	83 e0 03             	and    $0x3,%eax
  80335e:	83 f8 01             	cmp    $0x1,%eax
  803361:	75 23                	jne    803386 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  803363:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  803368:	8b 40 4c             	mov    0x4c(%eax),%eax
  80336b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80336f:	89 44 24 04          	mov    %eax,0x4(%esp)
  803373:	c7 04 24 3d 50 80 00 	movl   $0x80503d,(%esp)
  80337a:	e8 c6 eb ff ff       	call   801f45 <cprintf>
  80337f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  803384:	eb 63                	jmp    8033e9 <read+0xd6>
	}
	if (!dev->dev_read)
  803386:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80338b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80338e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  803392:	74 55                	je     8033e9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  803394:	ba 00 00 00 00       	mov    $0x0,%edx
  803399:	bb 00 00 00 00       	mov    $0x0,%ebx
  80339e:	b8 00 00 00 00       	mov    $0x0,%eax
  8033a3:	85 f6                	test   %esi,%esi
  8033a5:	74 42                	je     8033e9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  8033a7:	bf 00 10 00 00       	mov    $0x1000,%edi
  8033ac:	89 f0                	mov    %esi,%eax
  8033ae:	29 d0                	sub    %edx,%eax
  8033b0:	89 c1                	mov    %eax,%ecx
  8033b2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8033b8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8033bd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  8033c0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8033c4:	03 55 0c             	add    0xc(%ebp),%edx
  8033c7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8033cb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8033ce:	89 04 24             	mov    %eax,(%esp)
  8033d1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8033d4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8033d7:	85 c0                	test   %eax,%eax
  8033d9:	78 0e                	js     8033e9 <read+0xd6>
			return m;
		if (m == 0)
  8033db:	85 c0                	test   %eax,%eax
  8033dd:	74 08                	je     8033e7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8033df:	01 c3                	add    %eax,%ebx
  8033e1:	89 da                	mov    %ebx,%edx
  8033e3:	39 f3                	cmp    %esi,%ebx
  8033e5:	72 c5                	jb     8033ac <read+0x99>
  8033e7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8033e9:	83 c4 2c             	add    $0x2c,%esp
  8033ec:	5b                   	pop    %ebx
  8033ed:	5e                   	pop    %esi
  8033ee:	5f                   	pop    %edi
  8033ef:	5d                   	pop    %ebp
  8033f0:	c3                   	ret    

008033f1 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  8033f1:	55                   	push   %ebp
  8033f2:	89 e5                	mov    %esp,%ebp
  8033f4:	57                   	push   %edi
  8033f5:	56                   	push   %esi
  8033f6:	53                   	push   %ebx
  8033f7:	83 ec 1c             	sub    $0x1c,%esp
  8033fa:	8b 7d 08             	mov    0x8(%ebp),%edi
  8033fd:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  803400:	ba 00 00 00 00       	mov    $0x0,%edx
  803405:	bb 00 00 00 00       	mov    $0x0,%ebx
  80340a:	b8 00 00 00 00       	mov    $0x0,%eax
  80340f:	85 f6                	test   %esi,%esi
  803411:	74 29                	je     80343c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  803413:	89 f0                	mov    %esi,%eax
  803415:	29 d0                	sub    %edx,%eax
  803417:	89 44 24 08          	mov    %eax,0x8(%esp)
  80341b:	03 55 0c             	add    0xc(%ebp),%edx
  80341e:	89 54 24 04          	mov    %edx,0x4(%esp)
  803422:	89 3c 24             	mov    %edi,(%esp)
  803425:	e8 e9 fe ff ff       	call   803313 <read>
		if (m < 0)
  80342a:	85 c0                	test   %eax,%eax
  80342c:	78 0e                	js     80343c <readn+0x4b>
			return m;
		if (m == 0)
  80342e:	85 c0                	test   %eax,%eax
  803430:	74 08                	je     80343a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  803432:	01 c3                	add    %eax,%ebx
  803434:	89 da                	mov    %ebx,%edx
  803436:	39 f3                	cmp    %esi,%ebx
  803438:	72 d9                	jb     803413 <readn+0x22>
  80343a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80343c:	83 c4 1c             	add    $0x1c,%esp
  80343f:	5b                   	pop    %ebx
  803440:	5e                   	pop    %esi
  803441:	5f                   	pop    %edi
  803442:	5d                   	pop    %ebp
  803443:	c3                   	ret    

00803444 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  803444:	55                   	push   %ebp
  803445:	89 e5                	mov    %esp,%ebp
  803447:	83 ec 28             	sub    $0x28,%esp
  80344a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80344d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  803450:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  803453:	89 34 24             	mov    %esi,(%esp)
  803456:	e8 b5 fb ff ff       	call   803010 <fd2num>
  80345b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80345e:	89 54 24 04          	mov    %edx,0x4(%esp)
  803462:	89 04 24             	mov    %eax,(%esp)
  803465:	e8 43 fc ff ff       	call   8030ad <fd_lookup>
  80346a:	89 c3                	mov    %eax,%ebx
  80346c:	85 c0                	test   %eax,%eax
  80346e:	78 05                	js     803475 <fd_close+0x31>
  803470:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  803473:	74 0e                	je     803483 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  803475:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  803479:	b8 00 00 00 00       	mov    $0x0,%eax
  80347e:	0f 44 d8             	cmove  %eax,%ebx
  803481:	eb 3d                	jmp    8034c0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  803483:	8d 45 f0             	lea    -0x10(%ebp),%eax
  803486:	89 44 24 04          	mov    %eax,0x4(%esp)
  80348a:	8b 06                	mov    (%esi),%eax
  80348c:	89 04 24             	mov    %eax,(%esp)
  80348f:	e8 8d fc ff ff       	call   803121 <dev_lookup>
  803494:	89 c3                	mov    %eax,%ebx
  803496:	85 c0                	test   %eax,%eax
  803498:	78 16                	js     8034b0 <fd_close+0x6c>
		if (dev->dev_close)
  80349a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80349d:	8b 40 10             	mov    0x10(%eax),%eax
  8034a0:	bb 00 00 00 00       	mov    $0x0,%ebx
  8034a5:	85 c0                	test   %eax,%eax
  8034a7:	74 07                	je     8034b0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  8034a9:	89 34 24             	mov    %esi,(%esp)
  8034ac:	ff d0                	call   *%eax
  8034ae:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  8034b0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8034b4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8034bb:	e8 fa f7 ff ff       	call   802cba <sys_page_unmap>
	return r;
}
  8034c0:	89 d8                	mov    %ebx,%eax
  8034c2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8034c5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8034c8:	89 ec                	mov    %ebp,%esp
  8034ca:	5d                   	pop    %ebp
  8034cb:	c3                   	ret    

008034cc <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  8034cc:	55                   	push   %ebp
  8034cd:	89 e5                	mov    %esp,%ebp
  8034cf:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8034d2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8034d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8034d9:	8b 45 08             	mov    0x8(%ebp),%eax
  8034dc:	89 04 24             	mov    %eax,(%esp)
  8034df:	e8 c9 fb ff ff       	call   8030ad <fd_lookup>
  8034e4:	85 c0                	test   %eax,%eax
  8034e6:	78 13                	js     8034fb <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  8034e8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8034ef:	00 
  8034f0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8034f3:	89 04 24             	mov    %eax,(%esp)
  8034f6:	e8 49 ff ff ff       	call   803444 <fd_close>
}
  8034fb:	c9                   	leave  
  8034fc:	c3                   	ret    

008034fd <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  8034fd:	55                   	push   %ebp
  8034fe:	89 e5                	mov    %esp,%ebp
  803500:	83 ec 18             	sub    $0x18,%esp
  803503:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  803506:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  803509:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  803510:	00 
  803511:	8b 45 08             	mov    0x8(%ebp),%eax
  803514:	89 04 24             	mov    %eax,(%esp)
  803517:	e8 80 03 00 00       	call   80389c <open>
  80351c:	89 c3                	mov    %eax,%ebx
  80351e:	85 c0                	test   %eax,%eax
  803520:	78 1b                	js     80353d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  803522:	8b 45 0c             	mov    0xc(%ebp),%eax
  803525:	89 44 24 04          	mov    %eax,0x4(%esp)
  803529:	89 1c 24             	mov    %ebx,(%esp)
  80352c:	e8 5e fc ff ff       	call   80318f <fstat>
  803531:	89 c6                	mov    %eax,%esi
	close(fd);
  803533:	89 1c 24             	mov    %ebx,(%esp)
  803536:	e8 91 ff ff ff       	call   8034cc <close>
  80353b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80353d:	89 d8                	mov    %ebx,%eax
  80353f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  803542:	8b 75 fc             	mov    -0x4(%ebp),%esi
  803545:	89 ec                	mov    %ebp,%esp
  803547:	5d                   	pop    %ebp
  803548:	c3                   	ret    

00803549 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  803549:	55                   	push   %ebp
  80354a:	89 e5                	mov    %esp,%ebp
  80354c:	53                   	push   %ebx
  80354d:	83 ec 14             	sub    $0x14,%esp
  803550:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  803555:	89 1c 24             	mov    %ebx,(%esp)
  803558:	e8 6f ff ff ff       	call   8034cc <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  80355d:	83 c3 01             	add    $0x1,%ebx
  803560:	83 fb 20             	cmp    $0x20,%ebx
  803563:	75 f0                	jne    803555 <close_all+0xc>
		close(i);
}
  803565:	83 c4 14             	add    $0x14,%esp
  803568:	5b                   	pop    %ebx
  803569:	5d                   	pop    %ebp
  80356a:	c3                   	ret    

0080356b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80356b:	55                   	push   %ebp
  80356c:	89 e5                	mov    %esp,%ebp
  80356e:	83 ec 58             	sub    $0x58,%esp
  803571:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  803574:	89 75 f8             	mov    %esi,-0x8(%ebp)
  803577:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80357a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  80357d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  803580:	89 44 24 04          	mov    %eax,0x4(%esp)
  803584:	8b 45 08             	mov    0x8(%ebp),%eax
  803587:	89 04 24             	mov    %eax,(%esp)
  80358a:	e8 1e fb ff ff       	call   8030ad <fd_lookup>
  80358f:	89 c3                	mov    %eax,%ebx
  803591:	85 c0                	test   %eax,%eax
  803593:	0f 88 e0 00 00 00    	js     803679 <dup+0x10e>
		return r;
	close(newfdnum);
  803599:	89 3c 24             	mov    %edi,(%esp)
  80359c:	e8 2b ff ff ff       	call   8034cc <close>

	newfd = INDEX2FD(newfdnum);
  8035a1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  8035a7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  8035aa:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8035ad:	89 04 24             	mov    %eax,(%esp)
  8035b0:	e8 6b fa ff ff       	call   803020 <fd2data>
  8035b5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8035b7:	89 34 24             	mov    %esi,(%esp)
  8035ba:	e8 61 fa ff ff       	call   803020 <fd2data>
  8035bf:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  8035c2:	89 da                	mov    %ebx,%edx
  8035c4:	89 d8                	mov    %ebx,%eax
  8035c6:	c1 e8 16             	shr    $0x16,%eax
  8035c9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8035d0:	a8 01                	test   $0x1,%al
  8035d2:	74 43                	je     803617 <dup+0xac>
  8035d4:	c1 ea 0c             	shr    $0xc,%edx
  8035d7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8035de:	a8 01                	test   $0x1,%al
  8035e0:	74 35                	je     803617 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  8035e2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8035e9:	25 07 0e 00 00       	and    $0xe07,%eax
  8035ee:	89 44 24 10          	mov    %eax,0x10(%esp)
  8035f2:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8035f5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8035f9:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  803600:	00 
  803601:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  803605:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80360c:	e8 07 f7 ff ff       	call   802d18 <sys_page_map>
  803611:	89 c3                	mov    %eax,%ebx
  803613:	85 c0                	test   %eax,%eax
  803615:	78 3f                	js     803656 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  803617:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80361a:	89 c2                	mov    %eax,%edx
  80361c:	c1 ea 0c             	shr    $0xc,%edx
  80361f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  803626:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80362c:	89 54 24 10          	mov    %edx,0x10(%esp)
  803630:	89 74 24 0c          	mov    %esi,0xc(%esp)
  803634:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80363b:	00 
  80363c:	89 44 24 04          	mov    %eax,0x4(%esp)
  803640:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803647:	e8 cc f6 ff ff       	call   802d18 <sys_page_map>
  80364c:	89 c3                	mov    %eax,%ebx
  80364e:	85 c0                	test   %eax,%eax
  803650:	78 04                	js     803656 <dup+0xeb>
  803652:	89 fb                	mov    %edi,%ebx
  803654:	eb 23                	jmp    803679 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  803656:	89 74 24 04          	mov    %esi,0x4(%esp)
  80365a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803661:	e8 54 f6 ff ff       	call   802cba <sys_page_unmap>
	sys_page_unmap(0, nva);
  803666:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  803669:	89 44 24 04          	mov    %eax,0x4(%esp)
  80366d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803674:	e8 41 f6 ff ff       	call   802cba <sys_page_unmap>
	return r;
}
  803679:	89 d8                	mov    %ebx,%eax
  80367b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80367e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  803681:	8b 7d fc             	mov    -0x4(%ebp),%edi
  803684:	89 ec                	mov    %ebp,%esp
  803686:	5d                   	pop    %ebp
  803687:	c3                   	ret    

00803688 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  803688:	55                   	push   %ebp
  803689:	89 e5                	mov    %esp,%ebp
  80368b:	53                   	push   %ebx
  80368c:	83 ec 14             	sub    $0x14,%esp
  80368f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  803691:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  803697:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  80369e:	00 
  80369f:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  8036a6:	00 
  8036a7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8036ab:	89 14 24             	mov    %edx,(%esp)
  8036ae:	e8 8d f8 ff ff       	call   802f40 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8036b3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8036ba:	00 
  8036bb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8036bf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8036c6:	e8 e7 f8 ff ff       	call   802fb2 <ipc_recv>
}
  8036cb:	83 c4 14             	add    $0x14,%esp
  8036ce:	5b                   	pop    %ebx
  8036cf:	5d                   	pop    %ebp
  8036d0:	c3                   	ret    

008036d1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  8036d1:	55                   	push   %ebp
  8036d2:	89 e5                	mov    %esp,%ebp
  8036d4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  8036d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8036da:	8b 40 0c             	mov    0xc(%eax),%eax
  8036dd:	a3 00 60 80 00       	mov    %eax,0x806000
	fsipcbuf.set_size.req_size = newsize;
  8036e2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8036e5:	a3 04 60 80 00       	mov    %eax,0x806004
	return fsipc(FSREQ_SET_SIZE, NULL);
  8036ea:	ba 00 00 00 00       	mov    $0x0,%edx
  8036ef:	b8 02 00 00 00       	mov    $0x2,%eax
  8036f4:	e8 8f ff ff ff       	call   803688 <fsipc>
}
  8036f9:	c9                   	leave  
  8036fa:	c3                   	ret    

008036fb <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  8036fb:	55                   	push   %ebp
  8036fc:	89 e5                	mov    %esp,%ebp
  8036fe:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  803701:	8b 45 08             	mov    0x8(%ebp),%eax
  803704:	8b 40 0c             	mov    0xc(%eax),%eax
  803707:	a3 00 60 80 00       	mov    %eax,0x806000
	return fsipc(FSREQ_FLUSH, NULL);
  80370c:	ba 00 00 00 00       	mov    $0x0,%edx
  803711:	b8 06 00 00 00       	mov    $0x6,%eax
  803716:	e8 6d ff ff ff       	call   803688 <fsipc>
}
  80371b:	c9                   	leave  
  80371c:	c3                   	ret    

0080371d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80371d:	55                   	push   %ebp
  80371e:	89 e5                	mov    %esp,%ebp
  803720:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  803723:	ba 00 00 00 00       	mov    $0x0,%edx
  803728:	b8 08 00 00 00       	mov    $0x8,%eax
  80372d:	e8 56 ff ff ff       	call   803688 <fsipc>
}
  803732:	c9                   	leave  
  803733:	c3                   	ret    

00803734 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  803734:	55                   	push   %ebp
  803735:	89 e5                	mov    %esp,%ebp
  803737:	53                   	push   %ebx
  803738:	83 ec 14             	sub    $0x14,%esp
  80373b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80373e:	8b 45 08             	mov    0x8(%ebp),%eax
  803741:	8b 40 0c             	mov    0xc(%eax),%eax
  803744:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  803749:	ba 00 00 00 00       	mov    $0x0,%edx
  80374e:	b8 05 00 00 00       	mov    $0x5,%eax
  803753:	e8 30 ff ff ff       	call   803688 <fsipc>
  803758:	85 c0                	test   %eax,%eax
  80375a:	78 2b                	js     803787 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80375c:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  803763:	00 
  803764:	89 1c 24             	mov    %ebx,(%esp)
  803767:	e8 ae ee ff ff       	call   80261a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  80376c:	a1 80 60 80 00       	mov    0x806080,%eax
  803771:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  803777:	a1 84 60 80 00       	mov    0x806084,%eax
  80377c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  803782:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  803787:	83 c4 14             	add    $0x14,%esp
  80378a:	5b                   	pop    %ebx
  80378b:	5d                   	pop    %ebp
  80378c:	c3                   	ret    

0080378d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  80378d:	55                   	push   %ebp
  80378e:	89 e5                	mov    %esp,%ebp
  803790:	53                   	push   %ebx
  803791:	83 ec 14             	sub    $0x14,%esp
  803794:	8b 45 08             	mov    0x8(%ebp),%eax
  803797:	8b 55 0c             	mov    0xc(%ebp),%edx
  80379a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  80379d:	85 c0                	test   %eax,%eax
  80379f:	74 44                	je     8037e5 <devfile_write+0x58>
  8037a1:	85 d2                	test   %edx,%edx
  8037a3:	74 40                	je     8037e5 <devfile_write+0x58>
  8037a5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  8037ab:	77 38                	ja     8037e5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  8037ad:	8b 40 0c             	mov    0xc(%eax),%eax
  8037b0:	a3 00 60 80 00       	mov    %eax,0x806000
    fsipcbuf.write.req_n        = n;
  8037b5:	89 1d 04 60 80 00    	mov    %ebx,0x806004
    memmove(fsipcbuf.write.req_buf, buf, n);
  8037bb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8037bf:	89 54 24 04          	mov    %edx,0x4(%esp)
  8037c3:	c7 04 24 08 60 80 00 	movl   $0x806008,(%esp)
  8037ca:	e8 06 f0 ff ff       	call   8027d5 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  8037cf:	ba 00 00 00 00       	mov    $0x0,%edx
  8037d4:	b8 04 00 00 00       	mov    $0x4,%eax
  8037d9:	e8 aa fe ff ff       	call   803688 <fsipc>
        return r;
    return n;
  8037de:	85 c0                	test   %eax,%eax
  8037e0:	0f 49 c3             	cmovns %ebx,%eax
  8037e3:	eb 05                	jmp    8037ea <devfile_write+0x5d>
  8037e5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8037ea:	83 c4 14             	add    $0x14,%esp
  8037ed:	5b                   	pop    %ebx
  8037ee:	5d                   	pop    %ebp
  8037ef:	c3                   	ret    

008037f0 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  8037f0:	55                   	push   %ebp
  8037f1:	89 e5                	mov    %esp,%ebp
  8037f3:	83 ec 18             	sub    $0x18,%esp
  8037f6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8037f9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8037fc:	8b 45 08             	mov    0x8(%ebp),%eax
  8037ff:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  803802:	85 c0                	test   %eax,%eax
  803804:	74 04                	je     80380a <devfile_read+0x1a>
  803806:	85 f6                	test   %esi,%esi
  803808:	75 07                	jne    803811 <devfile_read+0x21>
  80380a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  80380f:	eb 39                	jmp    80384a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  803811:	8b 40 0c             	mov    0xc(%eax),%eax
  803814:	a3 00 60 80 00       	mov    %eax,0x806000
  fsipcbuf.read.req_n         = n;
  803819:	8b 45 10             	mov    0x10(%ebp),%eax
  80381c:	a3 04 60 80 00       	mov    %eax,0x806004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  803821:	ba 00 00 00 00       	mov    $0x0,%edx
  803826:	b8 03 00 00 00       	mov    $0x3,%eax
  80382b:	e8 58 fe ff ff       	call   803688 <fsipc>
  803830:	89 c3                	mov    %eax,%ebx
  803832:	85 c0                	test   %eax,%eax
  803834:	78 14                	js     80384a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  803836:	89 44 24 08          	mov    %eax,0x8(%esp)
  80383a:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  803841:	00 
  803842:	89 34 24             	mov    %esi,(%esp)
  803845:	e8 8b ef ff ff       	call   8027d5 <memmove>
  return r;
}
  80384a:	89 d8                	mov    %ebx,%eax
  80384c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80384f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  803852:	89 ec                	mov    %ebp,%esp
  803854:	5d                   	pop    %ebp
  803855:	c3                   	ret    

00803856 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  803856:	55                   	push   %ebp
  803857:	89 e5                	mov    %esp,%ebp
  803859:	53                   	push   %ebx
  80385a:	83 ec 14             	sub    $0x14,%esp
  80385d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  803860:	89 1c 24             	mov    %ebx,(%esp)
  803863:	e8 68 ed ff ff       	call   8025d0 <strlen>
  803868:	89 c2                	mov    %eax,%edx
  80386a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  80386f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  803875:	7f 1f                	jg     803896 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  803877:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80387b:	c7 04 24 00 60 80 00 	movl   $0x806000,(%esp)
  803882:	e8 93 ed ff ff       	call   80261a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  803887:	ba 00 00 00 00       	mov    $0x0,%edx
  80388c:	b8 07 00 00 00       	mov    $0x7,%eax
  803891:	e8 f2 fd ff ff       	call   803688 <fsipc>
}
  803896:	83 c4 14             	add    $0x14,%esp
  803899:	5b                   	pop    %ebx
  80389a:	5d                   	pop    %ebp
  80389b:	c3                   	ret    

0080389c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  80389c:	55                   	push   %ebp
  80389d:	89 e5                	mov    %esp,%ebp
  80389f:	83 ec 28             	sub    $0x28,%esp
  8038a2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8038a5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8038a8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  8038ab:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  8038b0:	85 f6                	test   %esi,%esi
  8038b2:	74 65                	je     803919 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  8038b4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  8038bb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8038be:	89 04 24             	mov    %eax,(%esp)
  8038c1:	e8 75 f7 ff ff       	call   80303b <fd_alloc>
  8038c6:	89 c3                	mov    %eax,%ebx
  8038c8:	85 c0                	test   %eax,%eax
  8038ca:	78 4d                	js     803919 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  8038cc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8038d0:	c7 04 24 00 60 80 00 	movl   $0x806000,(%esp)
  8038d7:	e8 3e ed ff ff       	call   80261a <strcpy>
	fsipcbuf.open.req_omode = mode;
  8038dc:	8b 45 0c             	mov    0xc(%ebp),%eax
  8038df:	a3 00 64 80 00       	mov    %eax,0x806400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  8038e4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8038e7:	b8 01 00 00 00       	mov    $0x1,%eax
  8038ec:	e8 97 fd ff ff       	call   803688 <fsipc>
  8038f1:	89 c3                	mov    %eax,%ebx
  8038f3:	85 c0                	test   %eax,%eax
  8038f5:	79 15                	jns    80390c <open+0x70>
    fd_close(f, 0);
  8038f7:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8038fe:	00 
  8038ff:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803902:	89 04 24             	mov    %eax,(%esp)
  803905:	e8 3a fb ff ff       	call   803444 <fd_close>
    return r;
  80390a:	eb 0d                	jmp    803919 <open+0x7d>
  }
  return fd2num(f);
  80390c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80390f:	89 04 24             	mov    %eax,(%esp)
  803912:	e8 f9 f6 ff ff       	call   803010 <fd2num>
  803917:	89 c3                	mov    %eax,%ebx
}
  803919:	89 d8                	mov    %ebx,%eax
  80391b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80391e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  803921:	89 ec                	mov    %ebp,%esp
  803923:	5d                   	pop    %ebp
  803924:	c3                   	ret    
  803925:	00 00                	add    %al,(%eax)
	...

00803928 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  803928:	55                   	push   %ebp
  803929:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  80392b:	8b 45 08             	mov    0x8(%ebp),%eax
  80392e:	89 c2                	mov    %eax,%edx
  803930:	c1 ea 16             	shr    $0x16,%edx
  803933:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80393a:	f6 c2 01             	test   $0x1,%dl
  80393d:	74 26                	je     803965 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  80393f:	c1 e8 0c             	shr    $0xc,%eax
  803942:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  803949:	a8 01                	test   $0x1,%al
  80394b:	74 18                	je     803965 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  80394d:	c1 e8 0c             	shr    $0xc,%eax
  803950:	8d 14 40             	lea    (%eax,%eax,2),%edx
  803953:	c1 e2 02             	shl    $0x2,%edx
  803956:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  80395b:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  803960:	0f b7 c0             	movzwl %ax,%eax
  803963:	eb 05                	jmp    80396a <pageref+0x42>
  803965:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80396a:	5d                   	pop    %ebp
  80396b:	c3                   	ret    
  80396c:	00 00                	add    %al,(%eax)
	...

00803970 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  803970:	55                   	push   %ebp
  803971:	89 e5                	mov    %esp,%ebp
  803973:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  803976:	c7 44 24 04 70 50 80 	movl   $0x805070,0x4(%esp)
  80397d:	00 
  80397e:	8b 45 0c             	mov    0xc(%ebp),%eax
  803981:	89 04 24             	mov    %eax,(%esp)
  803984:	e8 91 ec ff ff       	call   80261a <strcpy>
	return 0;
}
  803989:	b8 00 00 00 00       	mov    $0x0,%eax
  80398e:	c9                   	leave  
  80398f:	c3                   	ret    

00803990 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  803990:	55                   	push   %ebp
  803991:	89 e5                	mov    %esp,%ebp
  803993:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  803996:	8b 45 08             	mov    0x8(%ebp),%eax
  803999:	8b 40 0c             	mov    0xc(%eax),%eax
  80399c:	89 04 24             	mov    %eax,(%esp)
  80399f:	e8 9d 02 00 00       	call   803c41 <nsipc_close>
}
  8039a4:	c9                   	leave  
  8039a5:	c3                   	ret    

008039a6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8039a6:	55                   	push   %ebp
  8039a7:	89 e5                	mov    %esp,%ebp
  8039a9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8039ac:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8039b3:	00 
  8039b4:	8b 45 10             	mov    0x10(%ebp),%eax
  8039b7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8039bb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8039be:	89 44 24 04          	mov    %eax,0x4(%esp)
  8039c2:	8b 45 08             	mov    0x8(%ebp),%eax
  8039c5:	8b 40 0c             	mov    0xc(%eax),%eax
  8039c8:	89 04 24             	mov    %eax,(%esp)
  8039cb:	e8 ad 02 00 00       	call   803c7d <nsipc_send>
}
  8039d0:	c9                   	leave  
  8039d1:	c3                   	ret    

008039d2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  8039d2:	55                   	push   %ebp
  8039d3:	89 e5                	mov    %esp,%ebp
  8039d5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  8039d8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8039df:	00 
  8039e0:	8b 45 10             	mov    0x10(%ebp),%eax
  8039e3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8039e7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8039ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  8039ee:	8b 45 08             	mov    0x8(%ebp),%eax
  8039f1:	8b 40 0c             	mov    0xc(%eax),%eax
  8039f4:	89 04 24             	mov    %eax,(%esp)
  8039f7:	e8 f4 02 00 00       	call   803cf0 <nsipc_recv>
}
  8039fc:	c9                   	leave  
  8039fd:	c3                   	ret    

008039fe <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  8039fe:	55                   	push   %ebp
  8039ff:	89 e5                	mov    %esp,%ebp
  803a01:	56                   	push   %esi
  803a02:	53                   	push   %ebx
  803a03:	83 ec 20             	sub    $0x20,%esp
  803a06:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  803a08:	8d 45 f4             	lea    -0xc(%ebp),%eax
  803a0b:	89 04 24             	mov    %eax,(%esp)
  803a0e:	e8 28 f6 ff ff       	call   80303b <fd_alloc>
  803a13:	89 c3                	mov    %eax,%ebx
  803a15:	85 c0                	test   %eax,%eax
  803a17:	78 21                	js     803a3a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  803a19:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  803a20:	00 
  803a21:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803a24:	89 44 24 04          	mov    %eax,0x4(%esp)
  803a28:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803a2f:	e8 42 f3 ff ff       	call   802d76 <sys_page_alloc>
  803a34:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  803a36:	85 c0                	test   %eax,%eax
  803a38:	79 0a                	jns    803a44 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  803a3a:	89 34 24             	mov    %esi,(%esp)
  803a3d:	e8 ff 01 00 00       	call   803c41 <nsipc_close>
		return r;
  803a42:	eb 28                	jmp    803a6c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  803a44:	8b 15 84 d0 80 00    	mov    0x80d084,%edx
  803a4a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803a4d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  803a4f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803a52:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  803a59:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803a5c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  803a5f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803a62:	89 04 24             	mov    %eax,(%esp)
  803a65:	e8 a6 f5 ff ff       	call   803010 <fd2num>
  803a6a:	89 c3                	mov    %eax,%ebx
}
  803a6c:	89 d8                	mov    %ebx,%eax
  803a6e:	83 c4 20             	add    $0x20,%esp
  803a71:	5b                   	pop    %ebx
  803a72:	5e                   	pop    %esi
  803a73:	5d                   	pop    %ebp
  803a74:	c3                   	ret    

00803a75 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  803a75:	55                   	push   %ebp
  803a76:	89 e5                	mov    %esp,%ebp
  803a78:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  803a7b:	8b 45 10             	mov    0x10(%ebp),%eax
  803a7e:	89 44 24 08          	mov    %eax,0x8(%esp)
  803a82:	8b 45 0c             	mov    0xc(%ebp),%eax
  803a85:	89 44 24 04          	mov    %eax,0x4(%esp)
  803a89:	8b 45 08             	mov    0x8(%ebp),%eax
  803a8c:	89 04 24             	mov    %eax,(%esp)
  803a8f:	e8 61 01 00 00       	call   803bf5 <nsipc_socket>
  803a94:	85 c0                	test   %eax,%eax
  803a96:	78 05                	js     803a9d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  803a98:	e8 61 ff ff ff       	call   8039fe <alloc_sockfd>
}
  803a9d:	c9                   	leave  
  803a9e:	66 90                	xchg   %ax,%ax
  803aa0:	c3                   	ret    

00803aa1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  803aa1:	55                   	push   %ebp
  803aa2:	89 e5                	mov    %esp,%ebp
  803aa4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  803aa7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  803aaa:	89 54 24 04          	mov    %edx,0x4(%esp)
  803aae:	89 04 24             	mov    %eax,(%esp)
  803ab1:	e8 f7 f5 ff ff       	call   8030ad <fd_lookup>
  803ab6:	85 c0                	test   %eax,%eax
  803ab8:	78 15                	js     803acf <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  803aba:	8b 55 f4             	mov    -0xc(%ebp),%edx
  803abd:	8b 0a                	mov    (%edx),%ecx
  803abf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  803ac4:	3b 0d 84 d0 80 00    	cmp    0x80d084,%ecx
  803aca:	75 03                	jne    803acf <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  803acc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  803acf:	c9                   	leave  
  803ad0:	c3                   	ret    

00803ad1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  803ad1:	55                   	push   %ebp
  803ad2:	89 e5                	mov    %esp,%ebp
  803ad4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803ad7:	8b 45 08             	mov    0x8(%ebp),%eax
  803ada:	e8 c2 ff ff ff       	call   803aa1 <fd2sockid>
  803adf:	85 c0                	test   %eax,%eax
  803ae1:	78 0f                	js     803af2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  803ae3:	8b 55 0c             	mov    0xc(%ebp),%edx
  803ae6:	89 54 24 04          	mov    %edx,0x4(%esp)
  803aea:	89 04 24             	mov    %eax,(%esp)
  803aed:	e8 2d 01 00 00       	call   803c1f <nsipc_listen>
}
  803af2:	c9                   	leave  
  803af3:	c3                   	ret    

00803af4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  803af4:	55                   	push   %ebp
  803af5:	89 e5                	mov    %esp,%ebp
  803af7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803afa:	8b 45 08             	mov    0x8(%ebp),%eax
  803afd:	e8 9f ff ff ff       	call   803aa1 <fd2sockid>
  803b02:	85 c0                	test   %eax,%eax
  803b04:	78 16                	js     803b1c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  803b06:	8b 55 10             	mov    0x10(%ebp),%edx
  803b09:	89 54 24 08          	mov    %edx,0x8(%esp)
  803b0d:	8b 55 0c             	mov    0xc(%ebp),%edx
  803b10:	89 54 24 04          	mov    %edx,0x4(%esp)
  803b14:	89 04 24             	mov    %eax,(%esp)
  803b17:	e8 54 02 00 00       	call   803d70 <nsipc_connect>
}
  803b1c:	c9                   	leave  
  803b1d:	c3                   	ret    

00803b1e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  803b1e:	55                   	push   %ebp
  803b1f:	89 e5                	mov    %esp,%ebp
  803b21:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803b24:	8b 45 08             	mov    0x8(%ebp),%eax
  803b27:	e8 75 ff ff ff       	call   803aa1 <fd2sockid>
  803b2c:	85 c0                	test   %eax,%eax
  803b2e:	78 0f                	js     803b3f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  803b30:	8b 55 0c             	mov    0xc(%ebp),%edx
  803b33:	89 54 24 04          	mov    %edx,0x4(%esp)
  803b37:	89 04 24             	mov    %eax,(%esp)
  803b3a:	e8 1c 01 00 00       	call   803c5b <nsipc_shutdown>
}
  803b3f:	c9                   	leave  
  803b40:	c3                   	ret    

00803b41 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  803b41:	55                   	push   %ebp
  803b42:	89 e5                	mov    %esp,%ebp
  803b44:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803b47:	8b 45 08             	mov    0x8(%ebp),%eax
  803b4a:	e8 52 ff ff ff       	call   803aa1 <fd2sockid>
  803b4f:	85 c0                	test   %eax,%eax
  803b51:	78 16                	js     803b69 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  803b53:	8b 55 10             	mov    0x10(%ebp),%edx
  803b56:	89 54 24 08          	mov    %edx,0x8(%esp)
  803b5a:	8b 55 0c             	mov    0xc(%ebp),%edx
  803b5d:	89 54 24 04          	mov    %edx,0x4(%esp)
  803b61:	89 04 24             	mov    %eax,(%esp)
  803b64:	e8 46 02 00 00       	call   803daf <nsipc_bind>
}
  803b69:	c9                   	leave  
  803b6a:	c3                   	ret    

00803b6b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  803b6b:	55                   	push   %ebp
  803b6c:	89 e5                	mov    %esp,%ebp
  803b6e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803b71:	8b 45 08             	mov    0x8(%ebp),%eax
  803b74:	e8 28 ff ff ff       	call   803aa1 <fd2sockid>
  803b79:	85 c0                	test   %eax,%eax
  803b7b:	78 1f                	js     803b9c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  803b7d:	8b 55 10             	mov    0x10(%ebp),%edx
  803b80:	89 54 24 08          	mov    %edx,0x8(%esp)
  803b84:	8b 55 0c             	mov    0xc(%ebp),%edx
  803b87:	89 54 24 04          	mov    %edx,0x4(%esp)
  803b8b:	89 04 24             	mov    %eax,(%esp)
  803b8e:	e8 5b 02 00 00       	call   803dee <nsipc_accept>
  803b93:	85 c0                	test   %eax,%eax
  803b95:	78 05                	js     803b9c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  803b97:	e8 62 fe ff ff       	call   8039fe <alloc_sockfd>
}
  803b9c:	c9                   	leave  
  803b9d:	8d 76 00             	lea    0x0(%esi),%esi
  803ba0:	c3                   	ret    
	...

00803bb0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  803bb0:	55                   	push   %ebp
  803bb1:	89 e5                	mov    %esp,%ebp
  803bb3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  803bb6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  803bbc:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  803bc3:	00 
  803bc4:	c7 44 24 08 00 80 80 	movl   $0x808000,0x8(%esp)
  803bcb:	00 
  803bcc:	89 44 24 04          	mov    %eax,0x4(%esp)
  803bd0:	89 14 24             	mov    %edx,(%esp)
  803bd3:	e8 68 f3 ff ff       	call   802f40 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  803bd8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  803bdf:	00 
  803be0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  803be7:	00 
  803be8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  803beb:	89 04 24             	mov    %eax,(%esp)
  803bee:	e8 bf f3 ff ff       	call   802fb2 <ipc_recv>
    return r;
}
  803bf3:	c9                   	leave  
  803bf4:	c3                   	ret    

00803bf5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  803bf5:	55                   	push   %ebp
  803bf6:	89 e5                	mov    %esp,%ebp
  803bf8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  803bfb:	8b 45 08             	mov    0x8(%ebp),%eax
  803bfe:	a3 00 80 80 00       	mov    %eax,0x808000
	nsipcbuf.socket.req_type = type;
  803c03:	8b 45 0c             	mov    0xc(%ebp),%eax
  803c06:	a3 04 80 80 00       	mov    %eax,0x808004
	nsipcbuf.socket.req_protocol = protocol;
  803c0b:	8b 45 10             	mov    0x10(%ebp),%eax
  803c0e:	a3 08 80 80 00       	mov    %eax,0x808008
	return nsipc(NSREQ_SOCKET);
  803c13:	b8 09 00 00 00       	mov    $0x9,%eax
  803c18:	e8 93 ff ff ff       	call   803bb0 <nsipc>
}
  803c1d:	c9                   	leave  
  803c1e:	c3                   	ret    

00803c1f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  803c1f:	55                   	push   %ebp
  803c20:	89 e5                	mov    %esp,%ebp
  803c22:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  803c25:	8b 45 08             	mov    0x8(%ebp),%eax
  803c28:	a3 00 80 80 00       	mov    %eax,0x808000
	nsipcbuf.listen.req_backlog = backlog;
  803c2d:	8b 45 0c             	mov    0xc(%ebp),%eax
  803c30:	a3 04 80 80 00       	mov    %eax,0x808004
	return nsipc(NSREQ_LISTEN);
  803c35:	b8 06 00 00 00       	mov    $0x6,%eax
  803c3a:	e8 71 ff ff ff       	call   803bb0 <nsipc>
}
  803c3f:	c9                   	leave  
  803c40:	c3                   	ret    

00803c41 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  803c41:	55                   	push   %ebp
  803c42:	89 e5                	mov    %esp,%ebp
  803c44:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  803c47:	8b 45 08             	mov    0x8(%ebp),%eax
  803c4a:	a3 00 80 80 00       	mov    %eax,0x808000
	return nsipc(NSREQ_CLOSE);
  803c4f:	b8 04 00 00 00       	mov    $0x4,%eax
  803c54:	e8 57 ff ff ff       	call   803bb0 <nsipc>
}
  803c59:	c9                   	leave  
  803c5a:	c3                   	ret    

00803c5b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  803c5b:	55                   	push   %ebp
  803c5c:	89 e5                	mov    %esp,%ebp
  803c5e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  803c61:	8b 45 08             	mov    0x8(%ebp),%eax
  803c64:	a3 00 80 80 00       	mov    %eax,0x808000
	nsipcbuf.shutdown.req_how = how;
  803c69:	8b 45 0c             	mov    0xc(%ebp),%eax
  803c6c:	a3 04 80 80 00       	mov    %eax,0x808004
	return nsipc(NSREQ_SHUTDOWN);
  803c71:	b8 03 00 00 00       	mov    $0x3,%eax
  803c76:	e8 35 ff ff ff       	call   803bb0 <nsipc>
}
  803c7b:	c9                   	leave  
  803c7c:	c3                   	ret    

00803c7d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  803c7d:	55                   	push   %ebp
  803c7e:	89 e5                	mov    %esp,%ebp
  803c80:	53                   	push   %ebx
  803c81:	83 ec 14             	sub    $0x14,%esp
  803c84:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  803c87:	8b 45 08             	mov    0x8(%ebp),%eax
  803c8a:	a3 00 80 80 00       	mov    %eax,0x808000
	assert(size < 1600);
  803c8f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  803c95:	7e 24                	jle    803cbb <nsipc_send+0x3e>
  803c97:	c7 44 24 0c 7c 50 80 	movl   $0x80507c,0xc(%esp)
  803c9e:	00 
  803c9f:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  803ca6:	00 
  803ca7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  803cae:	00 
  803caf:	c7 04 24 88 50 80 00 	movl   $0x805088,(%esp)
  803cb6:	e8 c5 e1 ff ff       	call   801e80 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  803cbb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  803cbf:	8b 45 0c             	mov    0xc(%ebp),%eax
  803cc2:	89 44 24 04          	mov    %eax,0x4(%esp)
  803cc6:	c7 04 24 0c 80 80 00 	movl   $0x80800c,(%esp)
  803ccd:	e8 03 eb ff ff       	call   8027d5 <memmove>
	nsipcbuf.send.req_size = size;
  803cd2:	89 1d 04 80 80 00    	mov    %ebx,0x808004
	nsipcbuf.send.req_flags = flags;
  803cd8:	8b 45 14             	mov    0x14(%ebp),%eax
  803cdb:	a3 08 80 80 00       	mov    %eax,0x808008
	return nsipc(NSREQ_SEND);
  803ce0:	b8 08 00 00 00       	mov    $0x8,%eax
  803ce5:	e8 c6 fe ff ff       	call   803bb0 <nsipc>
}
  803cea:	83 c4 14             	add    $0x14,%esp
  803ced:	5b                   	pop    %ebx
  803cee:	5d                   	pop    %ebp
  803cef:	c3                   	ret    

00803cf0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  803cf0:	55                   	push   %ebp
  803cf1:	89 e5                	mov    %esp,%ebp
  803cf3:	56                   	push   %esi
  803cf4:	53                   	push   %ebx
  803cf5:	83 ec 10             	sub    $0x10,%esp
  803cf8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  803cfb:	8b 45 08             	mov    0x8(%ebp),%eax
  803cfe:	a3 00 80 80 00       	mov    %eax,0x808000
	nsipcbuf.recv.req_len = len;
  803d03:	89 35 04 80 80 00    	mov    %esi,0x808004
	nsipcbuf.recv.req_flags = flags;
  803d09:	8b 45 14             	mov    0x14(%ebp),%eax
  803d0c:	a3 08 80 80 00       	mov    %eax,0x808008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  803d11:	b8 07 00 00 00       	mov    $0x7,%eax
  803d16:	e8 95 fe ff ff       	call   803bb0 <nsipc>
  803d1b:	89 c3                	mov    %eax,%ebx
  803d1d:	85 c0                	test   %eax,%eax
  803d1f:	78 46                	js     803d67 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  803d21:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  803d26:	7f 04                	jg     803d2c <nsipc_recv+0x3c>
  803d28:	39 c6                	cmp    %eax,%esi
  803d2a:	7d 24                	jge    803d50 <nsipc_recv+0x60>
  803d2c:	c7 44 24 0c 94 50 80 	movl   $0x805094,0xc(%esp)
  803d33:	00 
  803d34:	c7 44 24 08 6d 46 80 	movl   $0x80466d,0x8(%esp)
  803d3b:	00 
  803d3c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  803d43:	00 
  803d44:	c7 04 24 88 50 80 00 	movl   $0x805088,(%esp)
  803d4b:	e8 30 e1 ff ff       	call   801e80 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  803d50:	89 44 24 08          	mov    %eax,0x8(%esp)
  803d54:	c7 44 24 04 00 80 80 	movl   $0x808000,0x4(%esp)
  803d5b:	00 
  803d5c:	8b 45 0c             	mov    0xc(%ebp),%eax
  803d5f:	89 04 24             	mov    %eax,(%esp)
  803d62:	e8 6e ea ff ff       	call   8027d5 <memmove>
	}

	return r;
}
  803d67:	89 d8                	mov    %ebx,%eax
  803d69:	83 c4 10             	add    $0x10,%esp
  803d6c:	5b                   	pop    %ebx
  803d6d:	5e                   	pop    %esi
  803d6e:	5d                   	pop    %ebp
  803d6f:	c3                   	ret    

00803d70 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  803d70:	55                   	push   %ebp
  803d71:	89 e5                	mov    %esp,%ebp
  803d73:	53                   	push   %ebx
  803d74:	83 ec 14             	sub    $0x14,%esp
  803d77:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  803d7a:	8b 45 08             	mov    0x8(%ebp),%eax
  803d7d:	a3 00 80 80 00       	mov    %eax,0x808000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  803d82:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  803d86:	8b 45 0c             	mov    0xc(%ebp),%eax
  803d89:	89 44 24 04          	mov    %eax,0x4(%esp)
  803d8d:	c7 04 24 04 80 80 00 	movl   $0x808004,(%esp)
  803d94:	e8 3c ea ff ff       	call   8027d5 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  803d99:	89 1d 14 80 80 00    	mov    %ebx,0x808014
	return nsipc(NSREQ_CONNECT);
  803d9f:	b8 05 00 00 00       	mov    $0x5,%eax
  803da4:	e8 07 fe ff ff       	call   803bb0 <nsipc>
}
  803da9:	83 c4 14             	add    $0x14,%esp
  803dac:	5b                   	pop    %ebx
  803dad:	5d                   	pop    %ebp
  803dae:	c3                   	ret    

00803daf <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  803daf:	55                   	push   %ebp
  803db0:	89 e5                	mov    %esp,%ebp
  803db2:	53                   	push   %ebx
  803db3:	83 ec 14             	sub    $0x14,%esp
  803db6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  803db9:	8b 45 08             	mov    0x8(%ebp),%eax
  803dbc:	a3 00 80 80 00       	mov    %eax,0x808000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  803dc1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  803dc5:	8b 45 0c             	mov    0xc(%ebp),%eax
  803dc8:	89 44 24 04          	mov    %eax,0x4(%esp)
  803dcc:	c7 04 24 04 80 80 00 	movl   $0x808004,(%esp)
  803dd3:	e8 fd e9 ff ff       	call   8027d5 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  803dd8:	89 1d 14 80 80 00    	mov    %ebx,0x808014
	return nsipc(NSREQ_BIND);
  803dde:	b8 02 00 00 00       	mov    $0x2,%eax
  803de3:	e8 c8 fd ff ff       	call   803bb0 <nsipc>
}
  803de8:	83 c4 14             	add    $0x14,%esp
  803deb:	5b                   	pop    %ebx
  803dec:	5d                   	pop    %ebp
  803ded:	c3                   	ret    

00803dee <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  803dee:	55                   	push   %ebp
  803def:	89 e5                	mov    %esp,%ebp
  803df1:	83 ec 18             	sub    $0x18,%esp
  803df4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  803df7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  803dfa:	8b 45 08             	mov    0x8(%ebp),%eax
  803dfd:	a3 00 80 80 00       	mov    %eax,0x808000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  803e02:	b8 01 00 00 00       	mov    $0x1,%eax
  803e07:	e8 a4 fd ff ff       	call   803bb0 <nsipc>
  803e0c:	89 c3                	mov    %eax,%ebx
  803e0e:	85 c0                	test   %eax,%eax
  803e10:	78 25                	js     803e37 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  803e12:	be 10 80 80 00       	mov    $0x808010,%esi
  803e17:	8b 06                	mov    (%esi),%eax
  803e19:	89 44 24 08          	mov    %eax,0x8(%esp)
  803e1d:	c7 44 24 04 00 80 80 	movl   $0x808000,0x4(%esp)
  803e24:	00 
  803e25:	8b 45 0c             	mov    0xc(%ebp),%eax
  803e28:	89 04 24             	mov    %eax,(%esp)
  803e2b:	e8 a5 e9 ff ff       	call   8027d5 <memmove>
		*addrlen = ret->ret_addrlen;
  803e30:	8b 16                	mov    (%esi),%edx
  803e32:	8b 45 10             	mov    0x10(%ebp),%eax
  803e35:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  803e37:	89 d8                	mov    %ebx,%eax
  803e39:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  803e3c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  803e3f:	89 ec                	mov    %ebp,%esp
  803e41:	5d                   	pop    %ebp
  803e42:	c3                   	ret    
	...

00803e50 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  803e50:	55                   	push   %ebp
  803e51:	89 e5                	mov    %esp,%ebp
  803e53:	83 ec 18             	sub    $0x18,%esp
  803e56:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  803e59:	89 75 fc             	mov    %esi,-0x4(%ebp)
  803e5c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  803e5f:	8b 45 08             	mov    0x8(%ebp),%eax
  803e62:	89 04 24             	mov    %eax,(%esp)
  803e65:	e8 b6 f1 ff ff       	call   803020 <fd2data>
  803e6a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  803e6c:	c7 44 24 04 a9 50 80 	movl   $0x8050a9,0x4(%esp)
  803e73:	00 
  803e74:	89 34 24             	mov    %esi,(%esp)
  803e77:	e8 9e e7 ff ff       	call   80261a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  803e7c:	8b 43 04             	mov    0x4(%ebx),%eax
  803e7f:	2b 03                	sub    (%ebx),%eax
  803e81:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  803e87:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  803e8e:	00 00 00 
	stat->st_dev = &devpipe;
  803e91:	c7 86 88 00 00 00 a0 	movl   $0x80d0a0,0x88(%esi)
  803e98:	d0 80 00 
	return 0;
}
  803e9b:	b8 00 00 00 00       	mov    $0x0,%eax
  803ea0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  803ea3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  803ea6:	89 ec                	mov    %ebp,%esp
  803ea8:	5d                   	pop    %ebp
  803ea9:	c3                   	ret    

00803eaa <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  803eaa:	55                   	push   %ebp
  803eab:	89 e5                	mov    %esp,%ebp
  803ead:	53                   	push   %ebx
  803eae:	83 ec 14             	sub    $0x14,%esp
  803eb1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  803eb4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  803eb8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803ebf:	e8 f6 ed ff ff       	call   802cba <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  803ec4:	89 1c 24             	mov    %ebx,(%esp)
  803ec7:	e8 54 f1 ff ff       	call   803020 <fd2data>
  803ecc:	89 44 24 04          	mov    %eax,0x4(%esp)
  803ed0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803ed7:	e8 de ed ff ff       	call   802cba <sys_page_unmap>
}
  803edc:	83 c4 14             	add    $0x14,%esp
  803edf:	5b                   	pop    %ebx
  803ee0:	5d                   	pop    %ebp
  803ee1:	c3                   	ret    

00803ee2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  803ee2:	55                   	push   %ebp
  803ee3:	89 e5                	mov    %esp,%ebp
  803ee5:	57                   	push   %edi
  803ee6:	56                   	push   %esi
  803ee7:	53                   	push   %ebx
  803ee8:	83 ec 2c             	sub    $0x2c,%esp
  803eeb:	89 c7                	mov    %eax,%edi
  803eed:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  803ef0:	a1 e0 d0 80 00       	mov    0x80d0e0,%eax
  803ef5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  803ef8:	89 3c 24             	mov    %edi,(%esp)
  803efb:	e8 28 fa ff ff       	call   803928 <pageref>
  803f00:	89 c6                	mov    %eax,%esi
  803f02:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  803f05:	89 04 24             	mov    %eax,(%esp)
  803f08:	e8 1b fa ff ff       	call   803928 <pageref>
  803f0d:	39 c6                	cmp    %eax,%esi
  803f0f:	0f 94 c0             	sete   %al
  803f12:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  803f15:	8b 15 e0 d0 80 00    	mov    0x80d0e0,%edx
  803f1b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  803f1e:	39 cb                	cmp    %ecx,%ebx
  803f20:	75 08                	jne    803f2a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  803f22:	83 c4 2c             	add    $0x2c,%esp
  803f25:	5b                   	pop    %ebx
  803f26:	5e                   	pop    %esi
  803f27:	5f                   	pop    %edi
  803f28:	5d                   	pop    %ebp
  803f29:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  803f2a:	83 f8 01             	cmp    $0x1,%eax
  803f2d:	75 c1                	jne    803ef0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  803f2f:	8b 52 58             	mov    0x58(%edx),%edx
  803f32:	89 44 24 0c          	mov    %eax,0xc(%esp)
  803f36:	89 54 24 08          	mov    %edx,0x8(%esp)
  803f3a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  803f3e:	c7 04 24 b0 50 80 00 	movl   $0x8050b0,(%esp)
  803f45:	e8 fb df ff ff       	call   801f45 <cprintf>
  803f4a:	eb a4                	jmp    803ef0 <_pipeisclosed+0xe>

00803f4c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  803f4c:	55                   	push   %ebp
  803f4d:	89 e5                	mov    %esp,%ebp
  803f4f:	57                   	push   %edi
  803f50:	56                   	push   %esi
  803f51:	53                   	push   %ebx
  803f52:	83 ec 1c             	sub    $0x1c,%esp
  803f55:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  803f58:	89 34 24             	mov    %esi,(%esp)
  803f5b:	e8 c0 f0 ff ff       	call   803020 <fd2data>
  803f60:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  803f62:	bf 00 00 00 00       	mov    $0x0,%edi
  803f67:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  803f6b:	75 54                	jne    803fc1 <devpipe_write+0x75>
  803f6d:	eb 60                	jmp    803fcf <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  803f6f:	89 da                	mov    %ebx,%edx
  803f71:	89 f0                	mov    %esi,%eax
  803f73:	e8 6a ff ff ff       	call   803ee2 <_pipeisclosed>
  803f78:	85 c0                	test   %eax,%eax
  803f7a:	74 07                	je     803f83 <devpipe_write+0x37>
  803f7c:	b8 00 00 00 00       	mov    $0x0,%eax
  803f81:	eb 53                	jmp    803fd6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  803f83:	90                   	nop
  803f84:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803f88:	e8 48 ee ff ff       	call   802dd5 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  803f8d:	8b 43 04             	mov    0x4(%ebx),%eax
  803f90:	8b 13                	mov    (%ebx),%edx
  803f92:	83 c2 20             	add    $0x20,%edx
  803f95:	39 d0                	cmp    %edx,%eax
  803f97:	73 d6                	jae    803f6f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  803f99:	89 c2                	mov    %eax,%edx
  803f9b:	c1 fa 1f             	sar    $0x1f,%edx
  803f9e:	c1 ea 1b             	shr    $0x1b,%edx
  803fa1:	01 d0                	add    %edx,%eax
  803fa3:	83 e0 1f             	and    $0x1f,%eax
  803fa6:	29 d0                	sub    %edx,%eax
  803fa8:	89 c2                	mov    %eax,%edx
  803faa:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  803fad:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  803fb1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  803fb5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  803fb9:	83 c7 01             	add    $0x1,%edi
  803fbc:	39 7d 10             	cmp    %edi,0x10(%ebp)
  803fbf:	76 13                	jbe    803fd4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  803fc1:	8b 43 04             	mov    0x4(%ebx),%eax
  803fc4:	8b 13                	mov    (%ebx),%edx
  803fc6:	83 c2 20             	add    $0x20,%edx
  803fc9:	39 d0                	cmp    %edx,%eax
  803fcb:	73 a2                	jae    803f6f <devpipe_write+0x23>
  803fcd:	eb ca                	jmp    803f99 <devpipe_write+0x4d>
  803fcf:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  803fd4:	89 f8                	mov    %edi,%eax
}
  803fd6:	83 c4 1c             	add    $0x1c,%esp
  803fd9:	5b                   	pop    %ebx
  803fda:	5e                   	pop    %esi
  803fdb:	5f                   	pop    %edi
  803fdc:	5d                   	pop    %ebp
  803fdd:	c3                   	ret    

00803fde <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  803fde:	55                   	push   %ebp
  803fdf:	89 e5                	mov    %esp,%ebp
  803fe1:	83 ec 28             	sub    $0x28,%esp
  803fe4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  803fe7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  803fea:	89 7d fc             	mov    %edi,-0x4(%ebp)
  803fed:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  803ff0:	89 3c 24             	mov    %edi,(%esp)
  803ff3:	e8 28 f0 ff ff       	call   803020 <fd2data>
  803ff8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  803ffa:	be 00 00 00 00       	mov    $0x0,%esi
  803fff:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  804003:	75 4c                	jne    804051 <devpipe_read+0x73>
  804005:	eb 5b                	jmp    804062 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  804007:	89 f0                	mov    %esi,%eax
  804009:	eb 5e                	jmp    804069 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80400b:	89 da                	mov    %ebx,%edx
  80400d:	89 f8                	mov    %edi,%eax
  80400f:	90                   	nop
  804010:	e8 cd fe ff ff       	call   803ee2 <_pipeisclosed>
  804015:	85 c0                	test   %eax,%eax
  804017:	74 07                	je     804020 <devpipe_read+0x42>
  804019:	b8 00 00 00 00       	mov    $0x0,%eax
  80401e:	eb 49                	jmp    804069 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  804020:	e8 b0 ed ff ff       	call   802dd5 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  804025:	8b 03                	mov    (%ebx),%eax
  804027:	3b 43 04             	cmp    0x4(%ebx),%eax
  80402a:	74 df                	je     80400b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80402c:	89 c2                	mov    %eax,%edx
  80402e:	c1 fa 1f             	sar    $0x1f,%edx
  804031:	c1 ea 1b             	shr    $0x1b,%edx
  804034:	01 d0                	add    %edx,%eax
  804036:	83 e0 1f             	and    $0x1f,%eax
  804039:	29 d0                	sub    %edx,%eax
  80403b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  804040:	8b 55 0c             	mov    0xc(%ebp),%edx
  804043:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  804046:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  804049:	83 c6 01             	add    $0x1,%esi
  80404c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80404f:	76 16                	jbe    804067 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  804051:	8b 03                	mov    (%ebx),%eax
  804053:	3b 43 04             	cmp    0x4(%ebx),%eax
  804056:	75 d4                	jne    80402c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  804058:	85 f6                	test   %esi,%esi
  80405a:	75 ab                	jne    804007 <devpipe_read+0x29>
  80405c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  804060:	eb a9                	jmp    80400b <devpipe_read+0x2d>
  804062:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  804067:	89 f0                	mov    %esi,%eax
}
  804069:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80406c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80406f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  804072:	89 ec                	mov    %ebp,%esp
  804074:	5d                   	pop    %ebp
  804075:	c3                   	ret    

00804076 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  804076:	55                   	push   %ebp
  804077:	89 e5                	mov    %esp,%ebp
  804079:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80407c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80407f:	89 44 24 04          	mov    %eax,0x4(%esp)
  804083:	8b 45 08             	mov    0x8(%ebp),%eax
  804086:	89 04 24             	mov    %eax,(%esp)
  804089:	e8 1f f0 ff ff       	call   8030ad <fd_lookup>
  80408e:	85 c0                	test   %eax,%eax
  804090:	78 15                	js     8040a7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  804092:	8b 45 f4             	mov    -0xc(%ebp),%eax
  804095:	89 04 24             	mov    %eax,(%esp)
  804098:	e8 83 ef ff ff       	call   803020 <fd2data>
	return _pipeisclosed(fd, p);
  80409d:	89 c2                	mov    %eax,%edx
  80409f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8040a2:	e8 3b fe ff ff       	call   803ee2 <_pipeisclosed>
}
  8040a7:	c9                   	leave  
  8040a8:	c3                   	ret    

008040a9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8040a9:	55                   	push   %ebp
  8040aa:	89 e5                	mov    %esp,%ebp
  8040ac:	83 ec 48             	sub    $0x48,%esp
  8040af:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8040b2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8040b5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8040b8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8040bb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8040be:	89 04 24             	mov    %eax,(%esp)
  8040c1:	e8 75 ef ff ff       	call   80303b <fd_alloc>
  8040c6:	89 c3                	mov    %eax,%ebx
  8040c8:	85 c0                	test   %eax,%eax
  8040ca:	0f 88 42 01 00 00    	js     804212 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8040d0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8040d7:	00 
  8040d8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8040db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8040df:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8040e6:	e8 8b ec ff ff       	call   802d76 <sys_page_alloc>
  8040eb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8040ed:	85 c0                	test   %eax,%eax
  8040ef:	0f 88 1d 01 00 00    	js     804212 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8040f5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8040f8:	89 04 24             	mov    %eax,(%esp)
  8040fb:	e8 3b ef ff ff       	call   80303b <fd_alloc>
  804100:	89 c3                	mov    %eax,%ebx
  804102:	85 c0                	test   %eax,%eax
  804104:	0f 88 f5 00 00 00    	js     8041ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80410a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  804111:	00 
  804112:	8b 45 e0             	mov    -0x20(%ebp),%eax
  804115:	89 44 24 04          	mov    %eax,0x4(%esp)
  804119:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  804120:	e8 51 ec ff ff       	call   802d76 <sys_page_alloc>
  804125:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  804127:	85 c0                	test   %eax,%eax
  804129:	0f 88 d0 00 00 00    	js     8041ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80412f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  804132:	89 04 24             	mov    %eax,(%esp)
  804135:	e8 e6 ee ff ff       	call   803020 <fd2data>
  80413a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80413c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  804143:	00 
  804144:	89 44 24 04          	mov    %eax,0x4(%esp)
  804148:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80414f:	e8 22 ec ff ff       	call   802d76 <sys_page_alloc>
  804154:	89 c3                	mov    %eax,%ebx
  804156:	85 c0                	test   %eax,%eax
  804158:	0f 88 8e 00 00 00    	js     8041ec <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80415e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  804161:	89 04 24             	mov    %eax,(%esp)
  804164:	e8 b7 ee ff ff       	call   803020 <fd2data>
  804169:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  804170:	00 
  804171:	89 44 24 0c          	mov    %eax,0xc(%esp)
  804175:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80417c:	00 
  80417d:	89 74 24 04          	mov    %esi,0x4(%esp)
  804181:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  804188:	e8 8b eb ff ff       	call   802d18 <sys_page_map>
  80418d:	89 c3                	mov    %eax,%ebx
  80418f:	85 c0                	test   %eax,%eax
  804191:	78 49                	js     8041dc <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  804193:	b8 a0 d0 80 00       	mov    $0x80d0a0,%eax
  804198:	8b 08                	mov    (%eax),%ecx
  80419a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80419d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80419f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8041a2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8041a9:	8b 10                	mov    (%eax),%edx
  8041ab:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8041ae:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8041b0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8041b3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8041ba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8041bd:	89 04 24             	mov    %eax,(%esp)
  8041c0:	e8 4b ee ff ff       	call   803010 <fd2num>
  8041c5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8041c7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8041ca:	89 04 24             	mov    %eax,(%esp)
  8041cd:	e8 3e ee ff ff       	call   803010 <fd2num>
  8041d2:	89 47 04             	mov    %eax,0x4(%edi)
  8041d5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  8041da:	eb 36                	jmp    804212 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  8041dc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8041e0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8041e7:	e8 ce ea ff ff       	call   802cba <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8041ec:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8041ef:	89 44 24 04          	mov    %eax,0x4(%esp)
  8041f3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8041fa:	e8 bb ea ff ff       	call   802cba <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  8041ff:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  804202:	89 44 24 04          	mov    %eax,0x4(%esp)
  804206:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80420d:	e8 a8 ea ff ff       	call   802cba <sys_page_unmap>
    err:
	return r;
}
  804212:	89 d8                	mov    %ebx,%eax
  804214:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  804217:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80421a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80421d:	89 ec                	mov    %ebp,%esp
  80421f:	5d                   	pop    %ebp
  804220:	c3                   	ret    
	...

00804230 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  804230:	55                   	push   %ebp
  804231:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  804233:	b8 00 00 00 00       	mov    $0x0,%eax
  804238:	5d                   	pop    %ebp
  804239:	c3                   	ret    

0080423a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80423a:	55                   	push   %ebp
  80423b:	89 e5                	mov    %esp,%ebp
  80423d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  804240:	c7 44 24 04 c8 50 80 	movl   $0x8050c8,0x4(%esp)
  804247:	00 
  804248:	8b 45 0c             	mov    0xc(%ebp),%eax
  80424b:	89 04 24             	mov    %eax,(%esp)
  80424e:	e8 c7 e3 ff ff       	call   80261a <strcpy>
	return 0;
}
  804253:	b8 00 00 00 00       	mov    $0x0,%eax
  804258:	c9                   	leave  
  804259:	c3                   	ret    

0080425a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80425a:	55                   	push   %ebp
  80425b:	89 e5                	mov    %esp,%ebp
  80425d:	57                   	push   %edi
  80425e:	56                   	push   %esi
  80425f:	53                   	push   %ebx
  804260:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  804266:	b8 00 00 00 00       	mov    $0x0,%eax
  80426b:	be 00 00 00 00       	mov    $0x0,%esi
  804270:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  804274:	74 41                	je     8042b7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  804276:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80427c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80427f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  804281:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  804287:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80428c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80428f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  804293:	03 45 0c             	add    0xc(%ebp),%eax
  804296:	89 44 24 04          	mov    %eax,0x4(%esp)
  80429a:	89 3c 24             	mov    %edi,(%esp)
  80429d:	e8 33 e5 ff ff       	call   8027d5 <memmove>
		sys_cputs(buf, m);
  8042a2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8042a6:	89 3c 24             	mov    %edi,(%esp)
  8042a9:	e8 62 e7 ff ff       	call   802a10 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  8042ae:	01 de                	add    %ebx,%esi
  8042b0:	89 f0                	mov    %esi,%eax
  8042b2:	3b 75 10             	cmp    0x10(%ebp),%esi
  8042b5:	72 c5                	jb     80427c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  8042b7:	89 f0                	mov    %esi,%eax
  8042b9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  8042bf:	5b                   	pop    %ebx
  8042c0:	5e                   	pop    %esi
  8042c1:	5f                   	pop    %edi
  8042c2:	5d                   	pop    %ebp
  8042c3:	c3                   	ret    

008042c4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  8042c4:	55                   	push   %ebp
  8042c5:	89 e5                	mov    %esp,%ebp
  8042c7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  8042ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8042cd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  8042d0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8042d7:	00 
  8042d8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8042db:	89 04 24             	mov    %eax,(%esp)
  8042de:	e8 2d e7 ff ff       	call   802a10 <sys_cputs>
}
  8042e3:	c9                   	leave  
  8042e4:	c3                   	ret    

008042e5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8042e5:	55                   	push   %ebp
  8042e6:	89 e5                	mov    %esp,%ebp
  8042e8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8042eb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8042ef:	75 07                	jne    8042f8 <devcons_read+0x13>
  8042f1:	eb 2d                	jmp    804320 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8042f3:	e8 dd ea ff ff       	call   802dd5 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8042f8:	90                   	nop
  8042f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  804300:	e8 d7 e6 ff ff       	call   8029dc <sys_cgetc>
  804305:	85 c0                	test   %eax,%eax
  804307:	74 ea                	je     8042f3 <devcons_read+0xe>
  804309:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  80430b:	85 c0                	test   %eax,%eax
  80430d:	78 16                	js     804325 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  80430f:	83 f8 04             	cmp    $0x4,%eax
  804312:	74 0c                	je     804320 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  804314:	8b 45 0c             	mov    0xc(%ebp),%eax
  804317:	88 10                	mov    %dl,(%eax)
  804319:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  80431e:	eb 05                	jmp    804325 <devcons_read+0x40>
  804320:	b8 00 00 00 00       	mov    $0x0,%eax
}
  804325:	c9                   	leave  
  804326:	c3                   	ret    

00804327 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  804327:	55                   	push   %ebp
  804328:	89 e5                	mov    %esp,%ebp
  80432a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  80432d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  804330:	89 04 24             	mov    %eax,(%esp)
  804333:	e8 03 ed ff ff       	call   80303b <fd_alloc>
  804338:	85 c0                	test   %eax,%eax
  80433a:	78 3f                	js     80437b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  80433c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  804343:	00 
  804344:	8b 45 f4             	mov    -0xc(%ebp),%eax
  804347:	89 44 24 04          	mov    %eax,0x4(%esp)
  80434b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  804352:	e8 1f ea ff ff       	call   802d76 <sys_page_alloc>
  804357:	85 c0                	test   %eax,%eax
  804359:	78 20                	js     80437b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80435b:	8b 15 bc d0 80 00    	mov    0x80d0bc,%edx
  804361:	8b 45 f4             	mov    -0xc(%ebp),%eax
  804364:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  804366:	8b 45 f4             	mov    -0xc(%ebp),%eax
  804369:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  804370:	8b 45 f4             	mov    -0xc(%ebp),%eax
  804373:	89 04 24             	mov    %eax,(%esp)
  804376:	e8 95 ec ff ff       	call   803010 <fd2num>
}
  80437b:	c9                   	leave  
  80437c:	c3                   	ret    

0080437d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80437d:	55                   	push   %ebp
  80437e:	89 e5                	mov    %esp,%ebp
  804380:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  804383:	8d 45 f4             	lea    -0xc(%ebp),%eax
  804386:	89 44 24 04          	mov    %eax,0x4(%esp)
  80438a:	8b 45 08             	mov    0x8(%ebp),%eax
  80438d:	89 04 24             	mov    %eax,(%esp)
  804390:	e8 18 ed ff ff       	call   8030ad <fd_lookup>
  804395:	85 c0                	test   %eax,%eax
  804397:	78 11                	js     8043aa <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  804399:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80439c:	8b 00                	mov    (%eax),%eax
  80439e:	3b 05 bc d0 80 00    	cmp    0x80d0bc,%eax
  8043a4:	0f 94 c0             	sete   %al
  8043a7:	0f b6 c0             	movzbl %al,%eax
}
  8043aa:	c9                   	leave  
  8043ab:	c3                   	ret    

008043ac <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  8043ac:	55                   	push   %ebp
  8043ad:	89 e5                	mov    %esp,%ebp
  8043af:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  8043b2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8043b9:	00 
  8043ba:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8043bd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8043c1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8043c8:	e8 46 ef ff ff       	call   803313 <read>
	if (r < 0)
  8043cd:	85 c0                	test   %eax,%eax
  8043cf:	78 0f                	js     8043e0 <getchar+0x34>
		return r;
	if (r < 1)
  8043d1:	85 c0                	test   %eax,%eax
  8043d3:	7f 07                	jg     8043dc <getchar+0x30>
  8043d5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8043da:	eb 04                	jmp    8043e0 <getchar+0x34>
		return -E_EOF;
	return c;
  8043dc:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8043e0:	c9                   	leave  
  8043e1:	c3                   	ret    
	...

008043f0 <__udivdi3>:
  8043f0:	55                   	push   %ebp
  8043f1:	89 e5                	mov    %esp,%ebp
  8043f3:	57                   	push   %edi
  8043f4:	56                   	push   %esi
  8043f5:	83 ec 10             	sub    $0x10,%esp
  8043f8:	8b 45 14             	mov    0x14(%ebp),%eax
  8043fb:	8b 55 08             	mov    0x8(%ebp),%edx
  8043fe:	8b 75 10             	mov    0x10(%ebp),%esi
  804401:	8b 7d 0c             	mov    0xc(%ebp),%edi
  804404:	85 c0                	test   %eax,%eax
  804406:	89 55 f0             	mov    %edx,-0x10(%ebp)
  804409:	75 35                	jne    804440 <__udivdi3+0x50>
  80440b:	39 fe                	cmp    %edi,%esi
  80440d:	77 61                	ja     804470 <__udivdi3+0x80>
  80440f:	85 f6                	test   %esi,%esi
  804411:	75 0b                	jne    80441e <__udivdi3+0x2e>
  804413:	b8 01 00 00 00       	mov    $0x1,%eax
  804418:	31 d2                	xor    %edx,%edx
  80441a:	f7 f6                	div    %esi
  80441c:	89 c6                	mov    %eax,%esi
  80441e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  804421:	31 d2                	xor    %edx,%edx
  804423:	89 f8                	mov    %edi,%eax
  804425:	f7 f6                	div    %esi
  804427:	89 c7                	mov    %eax,%edi
  804429:	89 c8                	mov    %ecx,%eax
  80442b:	f7 f6                	div    %esi
  80442d:	89 c1                	mov    %eax,%ecx
  80442f:	89 fa                	mov    %edi,%edx
  804431:	89 c8                	mov    %ecx,%eax
  804433:	83 c4 10             	add    $0x10,%esp
  804436:	5e                   	pop    %esi
  804437:	5f                   	pop    %edi
  804438:	5d                   	pop    %ebp
  804439:	c3                   	ret    
  80443a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  804440:	39 f8                	cmp    %edi,%eax
  804442:	77 1c                	ja     804460 <__udivdi3+0x70>
  804444:	0f bd d0             	bsr    %eax,%edx
  804447:	83 f2 1f             	xor    $0x1f,%edx
  80444a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80444d:	75 39                	jne    804488 <__udivdi3+0x98>
  80444f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  804452:	0f 86 a0 00 00 00    	jbe    8044f8 <__udivdi3+0x108>
  804458:	39 f8                	cmp    %edi,%eax
  80445a:	0f 82 98 00 00 00    	jb     8044f8 <__udivdi3+0x108>
  804460:	31 ff                	xor    %edi,%edi
  804462:	31 c9                	xor    %ecx,%ecx
  804464:	89 c8                	mov    %ecx,%eax
  804466:	89 fa                	mov    %edi,%edx
  804468:	83 c4 10             	add    $0x10,%esp
  80446b:	5e                   	pop    %esi
  80446c:	5f                   	pop    %edi
  80446d:	5d                   	pop    %ebp
  80446e:	c3                   	ret    
  80446f:	90                   	nop
  804470:	89 d1                	mov    %edx,%ecx
  804472:	89 fa                	mov    %edi,%edx
  804474:	89 c8                	mov    %ecx,%eax
  804476:	31 ff                	xor    %edi,%edi
  804478:	f7 f6                	div    %esi
  80447a:	89 c1                	mov    %eax,%ecx
  80447c:	89 fa                	mov    %edi,%edx
  80447e:	89 c8                	mov    %ecx,%eax
  804480:	83 c4 10             	add    $0x10,%esp
  804483:	5e                   	pop    %esi
  804484:	5f                   	pop    %edi
  804485:	5d                   	pop    %ebp
  804486:	c3                   	ret    
  804487:	90                   	nop
  804488:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80448c:	89 f2                	mov    %esi,%edx
  80448e:	d3 e0                	shl    %cl,%eax
  804490:	89 45 ec             	mov    %eax,-0x14(%ebp)
  804493:	b8 20 00 00 00       	mov    $0x20,%eax
  804498:	2b 45 f4             	sub    -0xc(%ebp),%eax
  80449b:	89 c1                	mov    %eax,%ecx
  80449d:	d3 ea                	shr    %cl,%edx
  80449f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8044a3:	0b 55 ec             	or     -0x14(%ebp),%edx
  8044a6:	d3 e6                	shl    %cl,%esi
  8044a8:	89 c1                	mov    %eax,%ecx
  8044aa:	89 75 e8             	mov    %esi,-0x18(%ebp)
  8044ad:	89 fe                	mov    %edi,%esi
  8044af:	d3 ee                	shr    %cl,%esi
  8044b1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8044b5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8044b8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8044bb:	d3 e7                	shl    %cl,%edi
  8044bd:	89 c1                	mov    %eax,%ecx
  8044bf:	d3 ea                	shr    %cl,%edx
  8044c1:	09 d7                	or     %edx,%edi
  8044c3:	89 f2                	mov    %esi,%edx
  8044c5:	89 f8                	mov    %edi,%eax
  8044c7:	f7 75 ec             	divl   -0x14(%ebp)
  8044ca:	89 d6                	mov    %edx,%esi
  8044cc:	89 c7                	mov    %eax,%edi
  8044ce:	f7 65 e8             	mull   -0x18(%ebp)
  8044d1:	39 d6                	cmp    %edx,%esi
  8044d3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8044d6:	72 30                	jb     804508 <__udivdi3+0x118>
  8044d8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8044db:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8044df:	d3 e2                	shl    %cl,%edx
  8044e1:	39 c2                	cmp    %eax,%edx
  8044e3:	73 05                	jae    8044ea <__udivdi3+0xfa>
  8044e5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  8044e8:	74 1e                	je     804508 <__udivdi3+0x118>
  8044ea:	89 f9                	mov    %edi,%ecx
  8044ec:	31 ff                	xor    %edi,%edi
  8044ee:	e9 71 ff ff ff       	jmp    804464 <__udivdi3+0x74>
  8044f3:	90                   	nop
  8044f4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8044f8:	31 ff                	xor    %edi,%edi
  8044fa:	b9 01 00 00 00       	mov    $0x1,%ecx
  8044ff:	e9 60 ff ff ff       	jmp    804464 <__udivdi3+0x74>
  804504:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  804508:	8d 4f ff             	lea    -0x1(%edi),%ecx
  80450b:	31 ff                	xor    %edi,%edi
  80450d:	89 c8                	mov    %ecx,%eax
  80450f:	89 fa                	mov    %edi,%edx
  804511:	83 c4 10             	add    $0x10,%esp
  804514:	5e                   	pop    %esi
  804515:	5f                   	pop    %edi
  804516:	5d                   	pop    %ebp
  804517:	c3                   	ret    
	...

00804520 <__umoddi3>:
  804520:	55                   	push   %ebp
  804521:	89 e5                	mov    %esp,%ebp
  804523:	57                   	push   %edi
  804524:	56                   	push   %esi
  804525:	83 ec 20             	sub    $0x20,%esp
  804528:	8b 55 14             	mov    0x14(%ebp),%edx
  80452b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80452e:	8b 7d 10             	mov    0x10(%ebp),%edi
  804531:	8b 75 0c             	mov    0xc(%ebp),%esi
  804534:	85 d2                	test   %edx,%edx
  804536:	89 c8                	mov    %ecx,%eax
  804538:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80453b:	75 13                	jne    804550 <__umoddi3+0x30>
  80453d:	39 f7                	cmp    %esi,%edi
  80453f:	76 3f                	jbe    804580 <__umoddi3+0x60>
  804541:	89 f2                	mov    %esi,%edx
  804543:	f7 f7                	div    %edi
  804545:	89 d0                	mov    %edx,%eax
  804547:	31 d2                	xor    %edx,%edx
  804549:	83 c4 20             	add    $0x20,%esp
  80454c:	5e                   	pop    %esi
  80454d:	5f                   	pop    %edi
  80454e:	5d                   	pop    %ebp
  80454f:	c3                   	ret    
  804550:	39 f2                	cmp    %esi,%edx
  804552:	77 4c                	ja     8045a0 <__umoddi3+0x80>
  804554:	0f bd ca             	bsr    %edx,%ecx
  804557:	83 f1 1f             	xor    $0x1f,%ecx
  80455a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  80455d:	75 51                	jne    8045b0 <__umoddi3+0x90>
  80455f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  804562:	0f 87 e0 00 00 00    	ja     804648 <__umoddi3+0x128>
  804568:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80456b:	29 f8                	sub    %edi,%eax
  80456d:	19 d6                	sbb    %edx,%esi
  80456f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  804572:	8b 45 f4             	mov    -0xc(%ebp),%eax
  804575:	89 f2                	mov    %esi,%edx
  804577:	83 c4 20             	add    $0x20,%esp
  80457a:	5e                   	pop    %esi
  80457b:	5f                   	pop    %edi
  80457c:	5d                   	pop    %ebp
  80457d:	c3                   	ret    
  80457e:	66 90                	xchg   %ax,%ax
  804580:	85 ff                	test   %edi,%edi
  804582:	75 0b                	jne    80458f <__umoddi3+0x6f>
  804584:	b8 01 00 00 00       	mov    $0x1,%eax
  804589:	31 d2                	xor    %edx,%edx
  80458b:	f7 f7                	div    %edi
  80458d:	89 c7                	mov    %eax,%edi
  80458f:	89 f0                	mov    %esi,%eax
  804591:	31 d2                	xor    %edx,%edx
  804593:	f7 f7                	div    %edi
  804595:	8b 45 f4             	mov    -0xc(%ebp),%eax
  804598:	f7 f7                	div    %edi
  80459a:	eb a9                	jmp    804545 <__umoddi3+0x25>
  80459c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8045a0:	89 c8                	mov    %ecx,%eax
  8045a2:	89 f2                	mov    %esi,%edx
  8045a4:	83 c4 20             	add    $0x20,%esp
  8045a7:	5e                   	pop    %esi
  8045a8:	5f                   	pop    %edi
  8045a9:	5d                   	pop    %ebp
  8045aa:	c3                   	ret    
  8045ab:	90                   	nop
  8045ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8045b0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8045b4:	d3 e2                	shl    %cl,%edx
  8045b6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8045b9:	ba 20 00 00 00       	mov    $0x20,%edx
  8045be:	2b 55 f0             	sub    -0x10(%ebp),%edx
  8045c1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8045c4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8045c8:	89 fa                	mov    %edi,%edx
  8045ca:	d3 ea                	shr    %cl,%edx
  8045cc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8045d0:	0b 55 f4             	or     -0xc(%ebp),%edx
  8045d3:	d3 e7                	shl    %cl,%edi
  8045d5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8045d9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8045dc:	89 f2                	mov    %esi,%edx
  8045de:	89 7d e8             	mov    %edi,-0x18(%ebp)
  8045e1:	89 c7                	mov    %eax,%edi
  8045e3:	d3 ea                	shr    %cl,%edx
  8045e5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8045e9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8045ec:	89 c2                	mov    %eax,%edx
  8045ee:	d3 e6                	shl    %cl,%esi
  8045f0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8045f4:	d3 ea                	shr    %cl,%edx
  8045f6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8045fa:	09 d6                	or     %edx,%esi
  8045fc:	89 f0                	mov    %esi,%eax
  8045fe:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  804601:	d3 e7                	shl    %cl,%edi
  804603:	89 f2                	mov    %esi,%edx
  804605:	f7 75 f4             	divl   -0xc(%ebp)
  804608:	89 d6                	mov    %edx,%esi
  80460a:	f7 65 e8             	mull   -0x18(%ebp)
  80460d:	39 d6                	cmp    %edx,%esi
  80460f:	72 2b                	jb     80463c <__umoddi3+0x11c>
  804611:	39 c7                	cmp    %eax,%edi
  804613:	72 23                	jb     804638 <__umoddi3+0x118>
  804615:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  804619:	29 c7                	sub    %eax,%edi
  80461b:	19 d6                	sbb    %edx,%esi
  80461d:	89 f0                	mov    %esi,%eax
  80461f:	89 f2                	mov    %esi,%edx
  804621:	d3 ef                	shr    %cl,%edi
  804623:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  804627:	d3 e0                	shl    %cl,%eax
  804629:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80462d:	09 f8                	or     %edi,%eax
  80462f:	d3 ea                	shr    %cl,%edx
  804631:	83 c4 20             	add    $0x20,%esp
  804634:	5e                   	pop    %esi
  804635:	5f                   	pop    %edi
  804636:	5d                   	pop    %ebp
  804637:	c3                   	ret    
  804638:	39 d6                	cmp    %edx,%esi
  80463a:	75 d9                	jne    804615 <__umoddi3+0xf5>
  80463c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  80463f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  804642:	eb d1                	jmp    804615 <__umoddi3+0xf5>
  804644:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  804648:	39 f2                	cmp    %esi,%edx
  80464a:	0f 82 18 ff ff ff    	jb     804568 <__umoddi3+0x48>
  804650:	e9 1d ff ff ff       	jmp    804572 <__umoddi3+0x52>
